Search in sources :

Example 26 with MaterialInstance

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));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) GoCipher(com.thoughtworks.go.security.GoCipher) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) Test(org.junit.Test)

Example 27 with 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));
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) GoCipher(com.thoughtworks.go.security.GoCipher) Material(com.thoughtworks.go.domain.materials.Material) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 28 with MaterialInstance

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
    }
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) IOException(java.io.IOException) Test(org.junit.Test)

Example 29 with MaterialInstance

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);
}
Also used : Modifications(com.thoughtworks.go.domain.materials.Modifications) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) File(java.io.File) Test(org.junit.Test)

Example 30 with MaterialInstance

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);
}
Also used : Material(com.thoughtworks.go.domain.materials.Material) PasswordAwareMaterial(com.thoughtworks.go.config.materials.PasswordAwareMaterial) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) Theory(org.junit.experimental.theories.Theory)

Aggregations

MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)39 Test (org.junit.Test)28 File (java.io.File)13 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)10 Modification (com.thoughtworks.go.domain.materials.Modification)9 Modifications (com.thoughtworks.go.domain.materials.Modifications)9 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)7 MaterialPollResult (com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult)7 SCMRevision (com.thoughtworks.go.plugin.access.scm.revision.SCMRevision)7 TransactionStatus (org.springframework.transaction.TransactionStatus)7 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)6 Date (java.util.Date)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)5 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)5 TfsMaterial (com.thoughtworks.go.config.materials.tfs.TfsMaterial)5 TransactionCallback (org.springframework.transaction.support.TransactionCallback)5 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)4 Material (com.thoughtworks.go.domain.materials.Material)4 HashMap (java.util.HashMap)4