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"));
}
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()));
}
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()));
}
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"));
}
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())));
}
Aggregations