Search in sources :

Example 6 with Properties

use of com.thoughtworks.go.domain.Properties 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 7 with Properties

use of com.thoughtworks.go.domain.Properties 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 8 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class PropertiesServiceTest method shouldLoadHistoryUptoSpecifiedPipeline.

@Test
public void shouldLoadHistoryUptoSpecifiedPipeline() {
    Pipeline pipeline1 = createNewPipeline();
    Pipeline pipeline2 = createNewPipeline();
    List<Properties> propertiesList = propertiesService.loadHistory(fixture.pipelineName, fixture.devStage, PipelineWithTwoStages.JOB_FOR_DEV_STAGE, pipeline2.getId(), 1);
    assertThat(propertiesList.size(), is(1));
    assertThat(propertiesList.get(0).getValue("cruise_pipeline_counter"), is(String.valueOf(pipeline2.getCounter())));
}
Also used : Properties(com.thoughtworks.go.domain.Properties) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 9 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class PropertiesServiceTest method shouldLoadOriginalJobPropertiesForGivenJobIdentifier.

@Test
public void shouldLoadOriginalJobPropertiesForGivenJobIdentifier() {
    Properties props = new Properties(new Property("a", "1"), new Property("b", "2"));
    PropertyDao propertyDao = mock(PropertyDao.class);
    JobResolverService resolver = mock(JobResolverService.class);
    PropertiesService service = new PropertiesService(propertyDao, null, null, resolver);
    JobIdentifier oldId = new JobIdentifier("pipeline-name", 10, "label-10", "stage-name", "3", "job-name", 9l);
    when(propertyDao.list(6l)).thenReturn(props);
    when(resolver.actualJobIdentifier(oldId)).thenReturn(new JobIdentifier("pipeline-name", 7, "label-7", "stage-name", "1", "job-name", 6l));
    assertThat(service.getPropertiesForOriginalJob(oldId), is(props));
}
Also used : PropertyDao(com.thoughtworks.go.server.dao.PropertyDao) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Properties(com.thoughtworks.go.domain.Properties) Property(com.thoughtworks.go.domain.Property) Test(org.junit.Test)

Example 10 with Properties

use of com.thoughtworks.go.domain.Properties in project gocd by gocd.

the class JobXmlViewModelTest method setUp.

@Before
public void setUp() {
    xmlWriterContext = mock(XmlWriterContext.class);
    jobPlan = mock(JobPlan.class);
    defaultJob = JobInstanceMother.completed("defaultJob");
    when(xmlWriterContext.planFor(defaultJob.getIdentifier())).thenReturn(jobPlan);
    when(xmlWriterContext.propertiesForJob(defaultJob.getId())).thenReturn(new Properties());
    jobXmlViewModel = new JobXmlViewModel(defaultJob);
}
Also used : JobPlan(com.thoughtworks.go.domain.JobPlan) XmlWriterContext(com.thoughtworks.go.domain.XmlWriterContext) Properties(com.thoughtworks.go.domain.Properties) Before(org.junit.Before)

Aggregations

Properties (com.thoughtworks.go.domain.Properties)13 Test (org.junit.Test)8 Property (com.thoughtworks.go.domain.Property)6 Pipeline (com.thoughtworks.go.domain.Pipeline)5 Csv (com.thoughtworks.go.util.Csv)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 JobPlan (com.thoughtworks.go.domain.JobPlan)1 XmlWriterContext (com.thoughtworks.go.domain.XmlWriterContext)1 PropertyDao (com.thoughtworks.go.server.dao.PropertyDao)1 JobDetailPresentationModel (com.thoughtworks.go.server.presentation.models.JobDetailPresentationModel)1 PropertiesService (com.thoughtworks.go.server.service.PropertiesService)1 ArrayList (java.util.ArrayList)1 Before (org.junit.Before)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1