Search in sources :

Example 6 with ArtifactPropertiesGenerator

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

the class BuildComposer method harvestProperties.

private BuildCommand harvestProperties() {
    List<ArtifactPropertiesGenerator> generators = assignment.getPlan().getPropertyGenerators();
    List<BuildCommand> commands = new ArrayList<>();
    for (ArtifactPropertiesGenerator generator : generators) {
        BuildCommand command = BuildCommand.generateProperty(generator.getName(), generator.getSrc(), generator.getXpath()).setWorkingDirectory(workingDirectory());
        commands.add(command);
    }
    return BuildCommand.compose(reportAction("Start to create properties"), BuildCommand.compose(commands));
}
Also used : ArrayList(java.util.ArrayList) BuildCommand(com.thoughtworks.go.domain.BuildCommand) ArtifactPropertiesGenerator(com.thoughtworks.go.config.ArtifactPropertiesGenerator)

Example 7 with ArtifactPropertiesGenerator

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

the class ArtifactPropertiesGeneratorTest method shouldReportPropertyIsCreated.

@Test
public void shouldReportPropertyIsCreated() throws Exception {
    String validXpath = "//buildplan/@name";
    generator = new ArtifactPropertiesGenerator(TEST_PROPERTY, createSrcFile().getName(), validXpath);
    generator.generate(goPublisherImple, workspace);
    assertThat(sentContents.get(0), containsString("Property " + TEST_PROPERTY + " = test created"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArtifactPropertiesGenerator(com.thoughtworks.go.config.ArtifactPropertiesGenerator) Test(org.junit.Test)

Example 8 with ArtifactPropertiesGenerator

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

the class ArtifactPropertiesGeneratorTest method shouldBeAbleToCreateACopyOfItself.

@Test
public void shouldBeAbleToCreateACopyOfItself() throws Exception {
    ArtifactPropertiesGenerator existingGenerator = new ArtifactPropertiesGenerator("prop1", "props.xml", "//some_xpath");
    existingGenerator.setId(2);
    existingGenerator.setJobId(10);
    existingGenerator.addError("abc", "def");
    assertThat(existingGenerator, equalTo(new ArtifactPropertiesGenerator(existingGenerator)));
    assertThat(existingGenerator, equalTo(new Cloner().deepClone(existingGenerator)));
}
Also used : ArtifactPropertiesGenerator(com.thoughtworks.go.config.ArtifactPropertiesGenerator) Cloner(com.rits.cloning.Cloner) Test(org.junit.Test)

Example 9 with ArtifactPropertiesGenerator

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

the class ArtifactPropertiesGeneratorTest method shouldReportFirstMatchedProperty.

@Test
public void shouldReportFirstMatchedProperty() throws Exception {
    String multipleMatchXPATH = "//artifact/@src";
    generator = new ArtifactPropertiesGenerator(TEST_PROPERTY, createSrcFile().getName(), multipleMatchXPATH);
    generator.generate(goPublisherImple, workspace);
    assertThat(sentContents.get(0), containsString("Property " + TEST_PROPERTY + " = target\\connectfour.jar created"));
}
Also used : CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ArtifactPropertiesGenerator(com.thoughtworks.go.config.ArtifactPropertiesGenerator) Test(org.junit.Test)

Example 10 with ArtifactPropertiesGenerator

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

the class ArtifactPropertiesGeneratorTest method shouldValidateThatNameIsMandatory.

@Test
public void shouldValidateThatNameIsMandatory() {
    ArtifactPropertiesGenerator generator = new ArtifactPropertiesGenerator(null, "props.xml", "//some_xpath");
    generator.validateTree(null);
    assertThat(generator.errors().on(ArtifactPropertiesGenerator.NAME), containsString("Invalid property name 'null'."));
}
Also used : 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