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