Changeset 18793 in josm for trunk/test/unit/org
- Timestamp:
- 2023-08-07T19:39:39+02:00 (15 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java
r17275 r18793 5 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertSame; 7 8 9 import java.util.Collection; 8 10 import java.util.Collections; 9 11 … … 11 13 import javax.swing.JPanel; 12 14 15 import mockit.Mock; 16 import mockit.MockUp; 13 17 import org.junit.jupiter.api.Test; 14 import org.junit. jupiter.api.extension.RegisterExtension;18 import org.junit.platform.commons.support.ReflectionSupport; 15 19 import org.openstreetmap.josm.TestUtils; 16 20 import org.openstreetmap.josm.data.osm.DataSet; … … 19 23 import org.openstreetmap.josm.data.osm.Relation; 20 24 import org.openstreetmap.josm.data.osm.Way; 25 import org.openstreetmap.josm.gui.dialogs.relation.actions.IRelationEditorActionAccess; 26 import org.openstreetmap.josm.gui.dialogs.relation.actions.PasteMembersAction; 21 27 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 28 import org.openstreetmap.josm.gui.tagging.TagEditorPanel; 23 29 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField; 24 import org.openstreetmap.josm.testutils.JOSMTestRules; 30 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler; 31 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 32 import org.openstreetmap.josm.testutils.annotations.Main; 25 33 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 26 27 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;28 34 29 35 /** 30 36 * Unit tests of {@link GenericRelationEditor} class. 31 37 */ 38 @BasicPreferences 39 @Main 32 40 public class GenericRelationEditorTest { 33 34 /**35 * Setup test.36 */37 @RegisterExtension38 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")39 public JOSMTestRules test = new JOSMTestRules().preferences().main();40 41 41 /** 42 42 * Returns a new relation editor for unit tests. … … 133 133 assertNotNull(tagEditorPanel.getModel()); 134 134 } 135 136 @Test 137 void testNonRegression23091() throws Exception { 138 new MockUp<PasteMembersAction>() { 139 @Mock 140 protected void updateEnabledState() { 141 // Do nothing 142 } 143 }; 144 145 DataSet ds = new DataSet(); 146 Relation relation = new Relation(1); 147 ds.addPrimitive(relation); 148 OsmDataLayer layer = new OsmDataLayer(ds, "test", null); 149 150 final GenericRelationEditor gr = new GenericRelationEditor(layer, relation, Collections.emptyList()); 151 final IRelationEditorActionAccess iAccess = (IRelationEditorActionAccess) 152 ReflectionSupport.tryToReadFieldValue(GenericRelationEditor.class.getDeclaredField("actionAccess"), gr) 153 .get(); 154 final TaggingPresetHandler handler = (TaggingPresetHandler) 155 ReflectionSupport.tryToReadFieldValue(MemberTableModel.class.getDeclaredField("presetHandler"), iAccess.getMemberTableModel()) 156 .get(); 157 final Collection<OsmPrimitive> selection = handler.getSelection(); 158 assertEquals(1, selection.size()); 159 assertSame(relation, selection.iterator().next(), "The selection should be the same"); 160 } 135 161 }
Note:
See TracChangeset
for help on using the changeset viewer.