diff --git a/src/test/java/hudson/plugins/mercurial/MercurialSCMTest.java b/src/test/java/hudson/plugins/mercurial/MercurialSCMTest.java index dd0de2da..a1549e0b 100644 --- a/src/test/java/hudson/plugins/mercurial/MercurialSCMTest.java +++ b/src/test/java/hudson/plugins/mercurial/MercurialSCMTest.java @@ -35,8 +35,6 @@ public class MercurialSCMTest { - public static final String EXPECTED_SHORT_ID = "123456789012"; - @Test public void parseStatus() throws Exception { assertEquals(new HashSet(Arrays.asList("whatever", "added", "mo-re", "whatever-c", "initial", "more")), MercurialSCM.parseStatus( "M whatever\n" @@ -50,40 +48,16 @@ public class MercurialSCMTest { } @Test public void buildEnvVarsSetsShortId() throws IOException { - Map < String, String > actualEnvironment = new HashMap(); - - createMercurialSCM().buildEnvVarsFromActionable(createActionable(), actualEnvironment); - + Map actualEnvironment = new HashMap(); + final String EXPECTED_SHORT_ID = "123456789012"; + new MercurialSCM("","","", "", "", null, true).buildEnvVarsFromActionable(new Actionable() { + @Override public List getActions() { + return Collections.singletonList(new MercurialTagAction(EXPECTED_SHORT_ID + "1627e63489b4096a8858e559a456", "rev", null)); + } + @Override public String getDisplayName() {return null;} + @Override public String getSearchUrl() {return null;} + }, actualEnvironment); assertEquals(EXPECTED_SHORT_ID, actualEnvironment.get("MERCURIAL_REVISION_SHORT")); } - private MercurialSCM createMercurialSCM() { - return new MercurialSCM("","","", "", "", null, true); - } - - private Actionable createActionable() { - List expectedActions = Arrays.asList((Action) new MercurialTagAction(EXPECTED_SHORT_ID + "1627e63489b4096a8858e559a456", "rev", null)); - return new ActionableTestDouble(expectedActions); - } - - private class ActionableTestDouble extends Actionable { - private List expectedActions = new ArrayList(); - - public ActionableTestDouble(List expectedActions) { - this.expectedActions = expectedActions; - } - - public String getDisplayName() { - throw new RuntimeException(); - } - - public String getSearchUrl() { - throw new RuntimeException(); - } - - @Override - public synchronized List getActions() { - return expectedActions; - } - } }