Search in sources :

Example 1 with Csv

use of com.thoughtworks.go.util.Csv in project gocd by gocd.

the class PropertiesControllerTest method shouldReturnAllHistoryIfNotLimitPipeline.

@Test
public void shouldReturnAllHistoryIfNotLimitPipeline() throws Exception {
    Pipeline pipeline1 = createNewPipeline();
    Pipeline pipeline2 = createNewPipeline();
    Pipeline pipeline3 = createNewPipeline();
    controller.jobsSearch(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, null, null, response);
    Csv csv = Csv.fromString(response.getContentAsString());
    assertThat(csv.rowCount(), is(3));
}
Also used : Csv(com.thoughtworks.go.util.Csv) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 2 with Csv

use of com.thoughtworks.go.util.Csv in project gocd by gocd.

the class PropertiesService method fromProperties.

public static Csv fromProperties(Properties properties) {
    Csv csv = new Csv();
    CsvRow row = csv.newRow();
    for (Property property : properties) {
        row.put(property.getKey(), property.getValue());
    }
    return csv;
}
Also used : CsvRow(com.thoughtworks.go.util.CsvRow) Csv(com.thoughtworks.go.util.Csv) Property(com.thoughtworks.go.domain.Property)

Example 3 with Csv

use of com.thoughtworks.go.util.Csv in project gocd by gocd.

the class PropertiesServiceTest method shouldGenerateFromProperties.

@Test
public void shouldGenerateFromProperties() throws Exception {
    Properties props = new Properties(new Property("a", "1"), new Property("b", "2"));
    Csv csv = PropertiesService.fromProperties(props);
    assertThat(csv.toString(), is("a,b\n" + "1,2\n"));
}
Also used : Csv(com.thoughtworks.go.util.Csv) Properties(com.thoughtworks.go.domain.Properties) Property(com.thoughtworks.go.domain.Property) Test(org.junit.Test)

Example 4 with Csv

use of com.thoughtworks.go.util.Csv in project gocd by gocd.

the class PropertiesServiceTest method shouldGenerateFromHistoryOfProperties.

@Test
public void shouldGenerateFromHistoryOfProperties() throws Exception {
    List<Properties> history = new ArrayList<>();
    history.add(new Properties(new Property("a", "100"), new Property("b", "200")));
    history.add(new Properties(new Property("a", "300"), new Property("b", "400")));
    Csv csv = PropertiesService.fromAllPropertiesHistory(history);
    assertThat(csv.toString(), is("a,b\n" + "100,200\n" + "300,400\n"));
}
Also used : Csv(com.thoughtworks.go.util.Csv) ArrayList(java.util.ArrayList) Properties(com.thoughtworks.go.domain.Properties) Property(com.thoughtworks.go.domain.Property) Test(org.junit.Test)

Example 5 with Csv

use of com.thoughtworks.go.util.Csv in project gocd by gocd.

the class PropertiesControllerTest method shouldSearchJobPropertiesUptoSpecifiedPipelineCounter.

@Test
public void shouldSearchJobPropertiesUptoSpecifiedPipelineCounter() throws Exception {
    Pipeline pipeline1 = createNewPipeline();
    Pipeline pipeline2 = createNewPipeline();
    Pipeline pipeline3 = createNewPipeline();
    controller.jobsSearch(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, String.valueOf(pipeline2.getCounter()), null, response);
    Csv csv = Csv.fromString(response.getContentAsString());
    assertThat(csv.containsRow(createCsvRow(pipeline1)), is(true));
    assertThat(csv.containsRow(createCsvRow(pipeline2)), is(true));
    assertThat(csv.containsRow(createCsvRow(pipeline3)), is(false));
}
Also used : Csv(com.thoughtworks.go.util.Csv) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Aggregations

Csv (com.thoughtworks.go.util.Csv)5 Test (org.junit.Test)4 Property (com.thoughtworks.go.domain.Property)3 Pipeline (com.thoughtworks.go.domain.Pipeline)2 Properties (com.thoughtworks.go.domain.Properties)2 CsvRow (com.thoughtworks.go.util.CsvRow)1 ArrayList (java.util.ArrayList)1