Ticket #16943: v1-0003-ChangesetCacheManagerTest-fix-testDownloadMyChang.patch

File v1-0003-ChangesetCacheManagerTest-fix-testDownloadMyChang.patch, 2.5 KB (added by ris, 7 years ago)
  • test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerTest.java

    From 94fccf4c1177d90fb66075a08d4e701923a1025a Mon Sep 17 00:00:00 2001
    From: Robert Scott <code@humanleg.org.uk>
    Date: Thu, 1 Nov 2018 23:31:28 +0000
    Subject: [PATCH v1 3/4] ChangesetCacheManagerTest: fix
     testDownloadMyChangesets for non-headless mode
    
    ---
     .../dialogs/changeset/ChangesetCacheManagerTest.java  | 19 +++++++++++++++++++
     1 file changed, 19 insertions(+)
    
    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheManagerTest.java
    index df518ea21..08456dae0 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.dialogs.changeset;
    33
     4import static org.junit.Assert.assertEquals;
    45import static org.junit.Assert.assertNotNull;
    56import static org.junit.Assert.assertTrue;
    67
    import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.Remove  
    2627import org.openstreetmap.josm.gui.dialogs.changeset.ChangesetCacheManager.ShowDetailAction;
    2728import org.openstreetmap.josm.gui.dialogs.changeset.query.ChangesetQueryDialog;
    2829import org.openstreetmap.josm.testutils.JOSMTestRules;
     30import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker;
    2931import org.openstreetmap.josm.testutils.mockers.WindowMocker;
    3032
     33import com.google.common.collect.ImmutableMap;
     34
    3135import mockit.Invocation;
    3236import mockit.Mock;
    3337import mockit.MockUp;
    public class ChangesetCacheManagerTest {  
    114118     */
    115119    @Test
    116120    public void testDownloadMyChangesets() {
     121        TestUtils.assumeWorkingJMockit();
     122        final HelpAwareOptionPaneMocker haMocker = new HelpAwareOptionPaneMocker(
     123            ImmutableMap.<String, Object>of(
     124                "<html>JOSM is currently running with an anonymous user. It cannot download<br>"
     125                + "your changesets from the OSM server unless you enter your OSM user name<br>"
     126                + "in the JOSM preferences.</html>",
     127                "OK"
     128            )
     129        );
     130
    117131        new DownloadMyChangesets().actionPerformed(null);
     132
     133        assertEquals(1, haMocker.getInvocationLog().size());
     134        Object[] invocationLogEntry = haMocker.getInvocationLog().get(0);
     135        assertEquals(0, (int) invocationLogEntry[0]);
     136        assertEquals("Warning", invocationLogEntry[2]);
    118137    }
    119138
    120139    /**