@Test public void shouldBuildSCMConfigurationFromResponseBody() throws Exception { String responseBody = "{" + "\"key-one\":{}," + "\"key-two\":{\"default-value\":\"two\",\"part-of-identity\":true,\"secure\":true,\"required\":true,\"display-name\":\"display-two\",\"display-order\":\"1\"}," + "\"key-three\":{\"default-value\":\"three\",\"part-of-identity\":false,\"secure\":false,\"required\":false,\"display-name\":\"display-three\",\"display-order\":\"2\"}" + "}"; SCMPropertyConfiguration scmConfiguration = messageHandler.responseMessageForSCMConfiguration(responseBody); assertPropertyConfiguration((SCMProperty) scmConfiguration.get("key-one"), "key-one", null, true, true, false, "", 0); assertPropertyConfiguration((SCMProperty) scmConfiguration.get("key-two"), "key-two", "two", true, true, true, "display-two", 1); assertPropertyConfiguration((SCMProperty) scmConfiguration.get("key-three"), "key-three", "three", false, false, false, "display-three", 2); }
@Test public void shouldTalkToPluginCheckoutForPrepare() { PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial(); pluggableSCMMaterial.setFolder("destination-folder"); Modification modification = ModificationsMother.oneModifiedFile("r1"); Map<String, String> additionalData = new HashMap<>(); additionalData.put("a1", "v1"); additionalData.put("a2", "v2"); modification.setAdditionalData(new Gson().toJson(additionalData)); MaterialRevision revision = new MaterialRevision(pluggableSCMMaterial, modification); String pipelineFolder = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath(); String destinationFolder = new File(pipelineFolder, "destination-folder").getAbsolutePath(); PluggableSCMMaterialAgent pluggableSCMMaterialAgent = new PluggableSCMMaterialAgent(scmExtension, revision, new File(pipelineFolder), consumer); when(scmExtension.checkout(eq("pluginid"), scmConfiguration.capture(), eq(destinationFolder), scmRevision.capture())).thenReturn(new Result()); pluggableSCMMaterialAgent.prepare(); verify(scmExtension).checkout(any(String.class), any(SCMPropertyConfiguration.class), any(String.class), any(SCMRevision.class)); assertThat(scmConfiguration.getValue().size(), is(2)); assertThat(scmConfiguration.getValue().get("k1").getValue(), is("v1")); assertThat(scmConfiguration.getValue().get("k2").getValue(), is("v2")); assertThat(scmRevision.getValue().getRevision(), is("r1")); assertThat(scmRevision.getValue().getTimestamp(), is(modification.getModifiedTime())); assertThat(scmRevision.getValue().getData().size(), is(2)); assertThat(scmRevision.getValue().getDataFor("a1"), is("v1")); assertThat(scmRevision.getValue().getDataFor("a2"), is("v2")); }