@Test public void shouldTestEqualsBasedOnConfiguration() { PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial("scm-id", "scm-name", ConfigurationPropertyMother.create("key1", false, "value1")); MaterialInstance materialInstance = material.createMaterialInstance(); MaterialInstance materialInstanceCopy = material.createMaterialInstance(); material.getScmConfig().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2")); MaterialInstance newMaterialInstance = material.createMaterialInstance(); assertThat(materialInstance, is(materialInstanceCopy)); assertThat(materialInstance, is(not(newMaterialInstance))); }
@Test public void shouldCreatePluggableSCMMaterialInstance() { PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial(); PluggableSCMMaterialInstance materialInstance = (PluggableSCMMaterialInstance) material.createMaterialInstance(); assertThat(materialInstance, is(notNullValue())); assertThat(materialInstance.getFlyweightName(), is(notNullValue())); assertThat(materialInstance.getConfiguration(), is(JsonHelper.toJsonString(material))); }
@Test public void shouldCorrectlyCheckIfUpgradeIsNecessary() { PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial("scm-id", "scm-name", ConfigurationPropertyMother.create("key1", false, "value1")); PluggableSCMMaterialInstance materialInstance = (PluggableSCMMaterialInstance) material.createMaterialInstance(); materialInstance.setId(10L); PluggableSCMMaterialInstance materialInstanceCopy = (PluggableSCMMaterialInstance) material.createMaterialInstance(); material.getScmConfig().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2")); PluggableSCMMaterialInstance newMaterialInstance = (PluggableSCMMaterialInstance) material.createMaterialInstance(); assertThat(materialInstance.shouldUpgradeTo(materialInstanceCopy), is(false)); assertThat(materialInstance.shouldUpgradeTo(newMaterialInstance), is(true)); }
@Test public void shouldCorrectlyCopyConfigurationValue() { PluggableSCMMaterialInstance materialInstance = (PluggableSCMMaterialInstance) MaterialsMother.pluggableSCMMaterial().createMaterialInstance(); materialInstance.setId(10L); PluggableSCMMaterial latestMaterial = MaterialsMother.pluggableSCMMaterial("scm-id", "scm-name", ConfigurationPropertyMother.create("key1", false, "value1")); PluggableSCMMaterialInstance newPluggableSCMMaterialInstance = (PluggableSCMMaterialInstance) latestMaterial.createMaterialInstance(); materialInstance.upgradeTo(newPluggableSCMMaterialInstance); assertThat(materialInstance.getId(), is(10L)); assertThat(materialInstance.getConfiguration(), is(newPluggableSCMMaterialInstance.getConfiguration())); }
@Test public void shouldAnswerRequiresUpdate() { PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial(); MaterialInstance materialInstance = material.createMaterialInstance();