Changeset 14385 in josm for trunk/test/unit


Ignore:
Timestamp:
2018-10-30T00:47:23+01:00 (5 years ago)
Author:
Don-vip
Message:

fix #16914 - GenericRelationEditorTest: fix for non-headless mode (patch by ris)

Location:
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java

    r14138 r14385  
    22package org.openstreetmap.josm.gui.dialogs.relation;
    33
     4import static org.junit.Assert.assertEquals;
    45import static org.junit.Assert.assertNotNull;
    56import static org.junit.Assert.assertNull;
     
    78import java.util.Collections;
    89
     10import javax.swing.JOptionPane;
    911import javax.swing.JPanel;
    1012
     
    2123import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
    2224import org.openstreetmap.josm.testutils.JOSMTestRules;
     25import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    2326
    2427import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    8386    @Test
    8487    public void testAddPrimitivesToRelation() {
     88        TestUtils.assumeWorkingJMockit();
     89        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker();
     90
    8591        Relation r = TestUtils.addFakeDataSet(new Relation(1));
    8692        assertNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.<OsmPrimitive>emptyList()));
     93
     94        jopsMocker.getMockResultMap().put(
     95            "<html>You are trying to add a relation to itself.<br><br>This creates circular references "
     96            + "and is therefore discouraged.<br>Skipping relation 'incomplete'.</html>",
     97            JOptionPane.OK_OPTION
     98        );
     99
    87100        assertNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Relation(1))));
     101
     102        assertEquals(1, jopsMocker.getInvocationLog().size());
     103        Object[] invocationLogEntry = jopsMocker.getInvocationLog().get(0);
     104        assertEquals(JOptionPane.OK_OPTION, (int) invocationLogEntry[0]);
     105        assertEquals("Warning", invocationLogEntry[2]);
    88106
    89107        assertNotNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Node(1))));
    90108        assertNotNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Way(1))));
    91109        assertNotNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Relation(2))));
     110
     111        assertEquals(1, jopsMocker.getInvocationLog().size());
    92112    }
    93113
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java

    r14380 r14385  
    1111import javax.swing.text.JTextComponent;
    1212
     13import org.openstreetmap.josm.TestUtils;
     14import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    1315import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    14 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
    1516
    1617import com.google.common.collect.ImmutableMap;
     
    7172    @Test
    7273    public void testDeleteCurrentRelationAction() {
     74        TestUtils.assumeWorkingJMockit();
    7375        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(
    7476            ImmutableMap.<String, Object>of(
     
    107109    @Test
    108110    public void testSetRoleAction() {
     111        TestUtils.assumeWorkingJMockit();
    109112        final JOptionPaneSimpleMocker.MessagePanelMocker mpMocker = new JOptionPaneSimpleMocker.MessagePanelMocker();
    110113        // JOptionPaneSimpleMocker doesn't handle showOptionDialog calls because of their potential
Note: See TracChangeset for help on using the changeset viewer.