Changeset 18991 in josm for trunk/test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java
- Timestamp:
- 2024-02-21T21:26:18+01:00 (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java
r18870 r18991 9 9 import java.awt.GraphicsEnvironment; 10 10 import java.net.URL; 11 import java.util.Collections; 11 import java.util.HashMap; 12 import java.util.Map; 12 13 13 14 import javax.swing.JOptionPane; 14 15 import javax.swing.JPanel; 15 16 16 import org.junit.jupiter.api.BeforeEach;17 17 import org.junit.jupiter.api.Test; 18 18 import org.openstreetmap.josm.TestUtils; 19 19 import org.openstreetmap.josm.data.UserIdentityManager; 20 20 import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard; 21 import org.openstreetmap.josm.spi.preferences.Config;22 21 import org.openstreetmap.josm.testutils.annotations.BasicPreferences; 23 22 import org.openstreetmap.josm.testutils.annotations.OsmApi; … … 64 63 65 64 /** 66 * These tests were written with {@link org.openstreetmap.josm.data.oauth.OAuthVersion#OAuth10a} as the default auth method.67 */68 @BeforeEach69 void setup() {70 Config.getPref().put("osm-server.auth-method", "oauth");71 }72 73 /**74 65 * Test of {@link DownloadOpenChangesetsTask} class when anonymous. 75 66 */ … … 80 71 new WindowMocker(); 81 72 } 82 final OAuthWizardMocker oaWizardMocker = new OAuthWizardMocker(); 83 final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker( 84 Collections.singletonMap( 85 "<html>Could not retrieve the list of your open changesets because<br>JOSM does not know " 73 final Map<String, Object> optionPaneMock = new HashMap<>(2); 74 optionPaneMock.put("<html>Could not retrieve the list of your open changesets because<br>JOSM does not know " 86 75 + "your identity.<br>You have either chosen to work anonymously or you are not " 87 + "entitled<br>to know the identity of the user on whose behalf you are working.</html>", JOptionPane.OK_OPTION 88 )89 );76 + "entitled<br>to know the identity of the user on whose behalf you are working.</html>", JOptionPane.OK_OPTION); 77 optionPaneMock.put("Obtain OAuth 2.0 token for authentication?", JOptionPane.NO_OPTION); 78 final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(optionPaneMock); 90 79 91 80 DownloadOpenChangesetsTask task = new DownloadOpenChangesetsTask(new JPanel()); … … 96 85 assertNull(task.getChangesets()); 97 86 98 assertEquals( 1, jopsMocker.getInvocationLog().size());99 Object[] invocationLogEntry = jopsMocker.getInvocationLog().get( 0);87 assertEquals(2, jopsMocker.getInvocationLog().size()); 88 Object[] invocationLogEntry = jopsMocker.getInvocationLog().get(1); 100 89 assertEquals(JOptionPane.OK_OPTION, (int) invocationLogEntry[0]); 101 90 assertEquals("Missing user identity", invocationLogEntry[2]); 102 91 103 assertTrue(oaWizardMocker.called); 92 invocationLogEntry = jopsMocker.getInvocationLog().get(0); 93 assertEquals(JOptionPane.NO_OPTION, (int) invocationLogEntry[0]); 94 assertEquals("Obtain authentication to OSM servers", invocationLogEntry[2]); 104 95 } 105 96 … … 113 104 new WindowMocker(); 114 105 } 115 final OAuthWizardMocker oaWizardMocker = new OAuthWizardMocker();116 final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(117 Collections.singletonMap("There are no open changesets", JOptionPane.OK_OPTION)118 );106 final Map<String, Object> optionPaneMock = new HashMap<>(2); 107 optionPaneMock.put("There are no open changesets", JOptionPane.OK_OPTION); 108 optionPaneMock.put("Obtain OAuth 2.0 token for authentication?", JOptionPane.NO_OPTION); 109 final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(optionPaneMock); 119 110 120 111 DownloadOpenChangesetsTask task = new DownloadOpenChangesetsTask(new JPanel()); … … 124 115 assertNotNull(task.getChangesets()); 125 116 126 assertEquals( 1, jopsMocker.getInvocationLog().size());127 Object[] invocationLogEntry = jopsMocker.getInvocationLog().get( 0);117 assertEquals(2, jopsMocker.getInvocationLog().size()); 118 Object[] invocationLogEntry = jopsMocker.getInvocationLog().get(1); 128 119 assertEquals(JOptionPane.OK_OPTION, (int) invocationLogEntry[0]); 129 120 assertEquals("No open changesets", invocationLogEntry[2]); 130 121 131 assertTrue(oaWizardMocker.called); 122 invocationLogEntry = jopsMocker.getInvocationLog().get(0); 123 assertEquals(JOptionPane.NO_OPTION, (int) invocationLogEntry[0]); 124 assertEquals("Obtain authentication to OSM servers", invocationLogEntry[2]); 132 125 } 133 126 }
Note:
See TracChangeset
for help on using the changeset viewer.