Search in sources :

Example 1 with ArtifactPropertiesGenerator

use of com.thoughtworks.go.config.ArtifactPropertiesGenerator in project gocd by gocd.

the class ArtifactPropertiesGeneratorTest method shouldAddErrorToErrorCollection.

@Test
public void shouldAddErrorToErrorCollection() throws IOException {
    String multipleMatchXPATH = "//artifact/@src";
    generator = new ArtifactPropertiesGenerator(TEST_PROPERTY, createSrcFile().getName(), multipleMatchXPATH);
    generator.addError("src", "Source invalid");
    assertThat(generator.errors().on("src"), is("Source invalid"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArtifactPropertiesGenerator(com.thoughtworks.go.config.ArtifactPropertiesGenerator) Test(org.junit.Test)

Example 2 with ArtifactPropertiesGenerator

use of com.thoughtworks.go.config.ArtifactPropertiesGenerator in project gocd by gocd.

the class ArtifactPropertiesGeneratorTest method shouldReportFailureWhenArtifactFileDoesNotExist.

@Test
public void shouldReportFailureWhenArtifactFileDoesNotExist() throws IOException {
    File workspaceNotExist = new File("dir-not-exist");
    File srcFile = new File(workspaceNotExist, "file.xml");
    generator = new ArtifactPropertiesGenerator(TEST_PROPERTY, srcFile.getName(), null);
    generator.generate(goPublisherImple, workspaceNotExist);
    assertThat(sentContents.get(0), containsString("Failed to create property"));
    assertThat(sentContents.get(0), containsString(srcFile.getAbsolutePath()));
}
Also used : File(java.io.File) ArtifactPropertiesGenerator(com.thoughtworks.go.config.ArtifactPropertiesGenerator) Test(org.junit.Test)

Example 3 with ArtifactPropertiesGenerator

use of com.thoughtworks.go.config.ArtifactPropertiesGenerator in project gocd by gocd.

the class ArtifactPropertiesGeneratorTest method shouldReportNotingMatchedWhenNoNodeCanMatch.

@Test
public void shouldReportNotingMatchedWhenNoNodeCanMatch() throws IOException {
    File srcFile = createSrcFile();
    String noNodeCanMatch = "//HTML";
    generator = new ArtifactPropertiesGenerator(TEST_PROPERTY, srcFile.getName(), noNodeCanMatch);
    generator.generate(goPublisherImple, workspace);
    assertThat(sentContents.get(0), containsString("Failed to create property"));
    assertThat(sentContents.get(0), containsString(srcFile.getAbsolutePath()));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) File(java.io.File) ArtifactPropertiesGenerator(com.thoughtworks.go.config.ArtifactPropertiesGenerator) Test(org.junit.Test)

Example 4 with ArtifactPropertiesGenerator

use of com.thoughtworks.go.config.ArtifactPropertiesGenerator in project gocd by gocd.

the class ArtifactPropertiesGeneratorTest method shouldReportNotingMatchedWhenXPATHisNotValid.

@Test
public void shouldReportNotingMatchedWhenXPATHisNotValid() throws IOException {
    String noNodeCanMatch = "////////HTML";
    generator = new ArtifactPropertiesGenerator(TEST_PROPERTY, createSrcFile().getName(), noNodeCanMatch);
    generator.generate(goPublisherImple, workspace);
    assertThat(sentErrors.get(0), containsString("Failed to create property"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArtifactPropertiesGenerator(com.thoughtworks.go.config.ArtifactPropertiesGenerator) Test(org.junit.Test)

Example 5 with ArtifactPropertiesGenerator

use of com.thoughtworks.go.config.ArtifactPropertiesGenerator in project gocd by gocd.

the class ArtifactPropertiesGeneratorRepositoryIntegrationTest method shouldSaveACopyOfAnArtifactPropertiesGenerator.

@Test
public void shouldSaveACopyOfAnArtifactPropertiesGenerator() {
    // Arrange
    JobInstance firstJobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME + "1"));
    JobInstance secondJobInstance = jobInstanceDao.save(stageId, new JobInstance(JOB_NAME + "2"));
    ArtifactPropertiesGenerator generator = new ArtifactPropertiesGenerator("test", "src", "//xpath");
    // Act
    ArtifactPropertiesGenerator generatorOfFirstJob = artifactPropertiesGeneratorRepository.saveCopyOf(firstJobInstance.getId(), generator);
    ArtifactPropertiesGenerator generatorOfSecondJob = artifactPropertiesGeneratorRepository.saveCopyOf(secondJobInstance.getId(), generator);
    // Assert
    List<ArtifactPropertiesGenerator> firstJobGenerators = artifactPropertiesGeneratorRepository.findByBuildId(firstJobInstance.getId());
    assertThat(firstJobGenerators.size(), is(1));
    assertThat(firstJobGenerators.get(0).getId(), equalTo(generatorOfFirstJob.getId()));
    assertThat(firstJobGenerators, hasItem(generatorOfFirstJob));
    List<ArtifactPropertiesGenerator> secondJobGenerators = artifactPropertiesGeneratorRepository.findByBuildId(secondJobInstance.getId());
    assertThat(secondJobGenerators.size(), is(1));
    assertThat(secondJobGenerators, hasItem(generatorOfSecondJob));
    assertThat(generatorOfFirstJob.getId(), not(equalTo(generatorOfSecondJob.getId())));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) ArtifactPropertiesGenerator(com.thoughtworks.go.config.ArtifactPropertiesGenerator) Test(org.junit.Test)

Aggregations

ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)13 Test (org.junit.Test)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 JobInstance (com.thoughtworks.go.domain.JobInstance)3 File (java.io.File)2 Cloner (com.rits.cloning.Cloner)1 BuildCommand (com.thoughtworks.go.domain.BuildCommand)1 ArrayList (java.util.ArrayList)1