From 81a52433b723abaedbe42b127cff6d583adbea5a Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Sat, 13 Oct 2018 19:14:29 +0100
Subject: [PATCH v1 2/3] ExtendedDialogMocker: add getContent utility method to
reduce boilerplate needed in test code
---
.../josm/testutils/mockers/ExtendedDialogMocker.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/test/unit/org/openstreetmap/josm/testutils/mockers/ExtendedDialogMocker.java b/test/unit/org/openstreetmap/josm/testutils/mockers/ExtendedDialogMocker.java
index e65e25c8a..b6ced5610 100644
|
a
|
b
|
import java.util.Map;
|
| 10 | 10 | import java.util.Optional; |
| 11 | 11 | import java.util.WeakHashMap; |
| 12 | 12 | |
| | 13 | import org.openstreetmap.josm.TestUtils; |
| 13 | 14 | import org.openstreetmap.josm.gui.ExtendedDialog; |
| 14 | 15 | import org.openstreetmap.josm.tools.Logging; |
| 15 | 16 | |
| … |
… |
public class ExtendedDialogMocker extends BaseDialogMockUp<ExtendedDialog> {
|
| 122 | 123 | }; |
| 123 | 124 | } |
| 124 | 125 | |
| | 126 | /** |
| | 127 | * A convenience method to access {@link ExtendedDialog#content} without exception-catching boilerplate |
| | 128 | */ |
| | 129 | protected Component getContent(final ExtendedDialog instance) { |
| | 130 | try { |
| | 131 | return (Component) TestUtils.getPrivateField(instance, "content"); |
| | 132 | } catch (ReflectiveOperationException e) { |
| | 133 | throw new RuntimeException(e); |
| | 134 | } |
| | 135 | } |
| | 136 | |
| 125 | 137 | @Mock |
| 126 | 138 | private void setupDialog(final Invocation invocation) { |
| 127 | 139 | if (!GraphicsEnvironment.isHeadless()) { |