@Override public String getLongDescription() { return getUriForDisplay(); }
@Override public void toJson(Map jsonMap, Revision revision) { jsonMap.put("scmType", getTypeForDisplay()); jsonMap.put("materialName", getDisplayName()); jsonMap.put("location", getUriForDisplay()); jsonMap.put("folder", getFolder()); jsonMap.put("action", "Modified"); }
@Override public String getDisplayName() { CaseInsensitiveString name = getName(); return (name == null || name.isBlank()) ? getUriForDisplay() : name.toString(); }
@Test public void shouldGetJsonRepresentationForPluggableSCMMaterial() { ConfigurationProperty k1 = create("k1", false, "v1"); SCM scmConfig = SCMMother.create("scm-id", "scm-name", "pluginid", "version", new Configuration(k1)); PluggableSCMMaterial material = new PluggableSCMMaterial(); material.setSCMConfig(scmConfig); material.setFolder("folder"); Map<String, String> jsonMap = new LinkedHashMap<>(); material.toJson(jsonMap, new PluggableSCMMaterialRevision("rev123", new Date())); assertThat(jsonMap.get("scmType"), is("SCM")); assertThat(jsonMap.get("materialName"), is("scm-name")); assertThat(jsonMap.get("location"), is(material.getUriForDisplay())); assertThat(jsonMap.get("folder"), is("folder")); assertThat(jsonMap.get("action"), is("Modified")); }
@Test public void shouldGetUriForDisplayNameIfNameIsNull() { ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "scm-v1"); ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", false, "scm-v2"); SCM scmConfig = SCMMother.create("scm-id", null, "pluginid", "version", new Configuration(k1, k2)); PluggableSCMMaterial material = new PluggableSCMMaterial(); material.setSCMConfig(scmConfig); assertThat(material.getDisplayName(), is(material.getUriForDisplay())); }
@Test public void shouldGetLongDescription() { ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "scm-v1"); ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", false, "scm-v2"); Configuration configuration = new Configuration(k1, k2); SCM scmConfig = SCMMother.create("scm-id", "scm-name", "pluginid", "version", configuration); PluggableSCMMaterial material = new PluggableSCMMaterial(); material.setSCMConfig(scmConfig); assertThat(material.getLongDescription(), is(material.getUriForDisplay())); }
@Test public void shouldGetUriForDisplay() { SCMMetadataStore.getInstance().addMetadataFor("some-plugin", new SCMConfigurations(), null); ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "scm-v1"); ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", false, "scm-v2"); Configuration configuration = new Configuration(k1, k2); SCM scmConfig = SCMMother.create("scm-id", "scm-name", "some-plugin", "version", configuration); PluggableSCMMaterial material = new PluggableSCMMaterial(); material.setSCMConfig(scmConfig); assertThat(material.getUriForDisplay(), is("[k1=scm-v1, k2=scm-v2]")); }