use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class TfsMaterialPersistenceTest method shouldSaveMaterialInstance.
@Test
public void shouldSaveMaterialInstance() throws Exception {
TfsMaterial tfsCfg = new TfsMaterial(new GoCipher(), new UrlArgument("url"), "loser", "CORPORATE", "foo_bar_baz", "/dev/null");
MaterialInstance materialInstance = materialRepository.findOrCreateFrom(tfsCfg);
assertThat(materialRepository.findMaterialInstance(tfsCfg), is(materialInstance));
}
use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class TfsMaterialPersistenceTest method shouldBeAbleToConvertAMaterialInstanceObjectToTfsMaterialObject.
@Test
public void shouldBeAbleToConvertAMaterialInstanceObjectToTfsMaterialObject() {
TfsMaterial tfsCfg = new TfsMaterial(new GoCipher(), new UrlArgument("url"), "loser", "CORPORATE", "password", "/dev/null");
tfsCfg.setFolder("folder");
tfsCfg.setName(new CaseInsensitiveString("materialName"));
MaterialInstance tfsInstance = materialRepository.findOrCreateFrom(tfsCfg);
Material material = tfsInstance.toOldMaterial("materialName", "folder", "password");
assertThat(material, is(tfsCfg));
}
use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class GoCacheTest method put_shouldBombWhenValueIsAPersistentObjectWithoutId.
@Test
public void put_shouldBombWhenValueIsAPersistentObjectWithoutId() throws Exception {
HgMaterial material = MaterialsMother.hgMaterial();
MaterialInstance materialInstance = material.createMaterialInstance();
try {
goCache.put("foo", materialInstance);
fail("should not allow getting a persistent object without id: " + materialInstance);
} catch (Exception e) {
// ok
}
}
use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class PluggableSCMMaterialUpdaterTest method shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed.
@Test
public void shouldUpdateToNewMaterialInstanceWhenConfigHas_Changed() throws Exception {
PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
MaterialInstance materialInstance = material.createMaterialInstance();
materialInstance.setId(1);
material.getScmConfig().getConfiguration().add(ConfigurationPropertyMother.create("key2", false, "value2"));
MaterialInstance newMaterialInstance = material.createMaterialInstance();
newMaterialInstance.setId(1);
File file = new File("random");
Modifications modifications = new Modifications();
when(materialRepository.find(anyLong())).thenReturn(materialInstance);
materialUpdater.insertLatestOrNewModifications(material, materialInstance, file, modifications);
verify(materialRepository).saveOrUpdate(newMaterialInstance);
verify(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, file, modifications);
}
use of com.thoughtworks.go.domain.MaterialInstance in project gocd by gocd.
the class MagicalMaterialAndMaterialConfigConversionTest method shouldBeSameObject_WhenConversionIsDoneFromMaterialToMaterialInstanceAndBack.
@Theory
public void shouldBeSameObject_WhenConversionIsDoneFromMaterialToMaterialInstanceAndBack(MaterialConfig materialConfig) throws Exception {
Material material = materialConfigConverter.toMaterial(materialConfig);
MaterialInstance materialInstance = material.createMaterialInstance();
Material materialConvertedBackFromInstance = materialInstance.toOldMaterial(materialConfig.getName().toString(), materialConfig.getFolder(), "pass");
assertTrue(message("Material <-> MaterialInstance conversion failed.", material, materialConvertedBackFromInstance), reflectionEquals(material, materialConvertedBackFromInstance, fieldsWhichShouldBeIgnoredWhenSavedInDbAndGotBack.get(materialConfig.getClass())));
assertThat(materialInstance.getFingerprint(), is(material.getFingerprint()));
assertThat(materialConvertedBackFromInstance.getFingerprint(), is(materialInstance.getFingerprint()));
assertPasswordIsCorrect(material);
assertPasswordIsCorrect(materialConvertedBackFromInstance);
}
Aggregations