Ticket #16010: v2-0012-PluginPreferenceTest-convert-to-use-of-HelpAwareO.patch

File v2-0012-PluginPreferenceTest-convert-to-use-of-HelpAwareO.patch, 2.7 KB (added by ris, 11 months ago)
  • test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java

    From 79a2a00607b2afd46dd5d7c857bc2203db6f3c79 Mon Sep 17 00:00:00 2001
    From: Robert Scott <code@humanleg.org.uk>
    Date: Tue, 27 Mar 2018 19:21:17 +0100
    Subject: [PATCH v2 12/28] PluginPreferenceTest: convert to use of
     HelpAwareOptionPaneMocker
    
    ---
     .../preferences/plugin/PluginPreferenceTest.java   | 23 +++++++++++++++-------
     1 file changed, 16 insertions(+), 7 deletions(-)
    
    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java
    index 9731f9e34..7c89cd081 100644
    a b import java.util.Arrays; 
    99import java.util.Collection;
    1010import java.util.Collections;
    1111
    12 import org.junit.BeforeClass;
     12import org.junit.Rule;
    1313import org.junit.Test;
    14 import org.openstreetmap.josm.JOSMFixture;
    1514import org.openstreetmap.josm.TestUtils;
    1615import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
    1716import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1817import org.openstreetmap.josm.plugins.PluginDownloadTask;
    1918import org.openstreetmap.josm.plugins.PluginException;
    2019import org.openstreetmap.josm.plugins.PluginInformation;
     20import org.openstreetmap.josm.testutils.HelpAwareOptionPaneMocker;
     21import org.openstreetmap.josm.testutils.JOSMTestRules;
     22
     23import com.google.common.collect.ImmutableMap;
     24
     25import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2126
    2227/**
    2328 * Unit tests of {@link PluginPreference} class.
    2429 */
    2530public class PluginPreferenceTest {
    26 
    2731    /**
    2832     * Setup test.
    2933     */
    30     @BeforeClass
    31     public static void setUpBeforeClass() {
    32         JOSMFixture.createUnitTestFixture().init();
    33     }
     34    @Rule
     35    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     36    public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT();
    3437
    3538    /**
    3639     * Unit test of {@link PluginPreference#PluginPreference}.
    public class PluginPreferenceTest { 
    8891     */
    8992    @Test
    9093    public void testNotifyDownloadResults() {
     94        new HelpAwareOptionPaneMocker(ImmutableMap.<String, Object>builder()
     95            .put("<html></html>", "OK")  // (buildDownloadSummary() output was empty)
     96            .put("<html>Please restart JOSM to activate the downloaded plugins.</html>", "OK")
     97            .build()
     98        );
     99
    91100        PluginDownloadTask task = new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), "");
    92101        PluginPreference.notifyDownloadResults(null, task, false);
    93102        PluginPreference.notifyDownloadResults(null, task, true);