use of com.thoughtworks.go.util.JsonValue in project gocd by gocd.
the class P4MaterialTestBase method shouldBeAbleToConvertToJson.
@Test
public void shouldBeAbleToConvertToJson() {
P4Material p4Material = p4Fixture.material(VIEW);
Map<String, Object> json = new LinkedHashMap<>();
p4Material.toJson(json, new StringRevision("123"));
JsonValue jsonValue = from(json);
assertThat(jsonValue.getString("scmType"), is("Perforce"));
assertThat(jsonValue.getString("location"), is(p4Material.getServerAndPort()));
assertThat(jsonValue.getString("action"), is("Modified"));
}
use of com.thoughtworks.go.util.JsonValue in project gocd by gocd.
the class GitMaterialTest method shouldBeAbleToConvertToJson.
@Test
public void shouldBeAbleToConvertToJson() {
Map<String, Object> json = new LinkedHashMap<>();
git.toJson(json, new StringRevision("123"));
JsonValue jsonValue = from(json);
assertThat(jsonValue.getString("scmType"), is("Git"));
assertThat(new File(jsonValue.getString("location")), is(new File(git.getUrl())));
assertThat(jsonValue.getString("action"), is("Modified"));
}
use of com.thoughtworks.go.util.JsonValue in project gocd by gocd.
the class SvnMaterialTest method shouldBeAbleToConvertToJson.
@Test
public void shouldBeAbleToConvertToJson() {
SvnMaterial material = MaterialsMother.svnMaterial("url");
Map<String, Object> json = new LinkedHashMap<>();
material.toJson(json, revision);
JsonValue jsonValue = from(json);
assertThat(jsonValue.getString("scmType"), is("Subversion"));
assertThat(new File(jsonValue.getString("location")), is(new File(material.getUrl())));
assertThat(jsonValue.getString("action"), is("Modified"));
}
use of com.thoughtworks.go.util.JsonValue in project gocd by gocd.
the class MaterialRevisionsJsonBuilderTest method shouldRenderDependencyMaterialRevision.
@Test
public void shouldRenderDependencyMaterialRevision() {
String revision = "cruise/10/dev/1";
MaterialRevisions revisions = new MaterialRevisions(new MaterialRevision(new DependencyMaterial(new CaseInsensitiveString("cruise"), new CaseInsensitiveString("dev")), new Modification(new Date(), revision, "MOCK_LABEL-12", null)));
MaterialRevisionsJsonBuilder jsonBuilder = new MaterialRevisionsJsonBuilder(new TrackingTool());
revisions.accept(jsonBuilder);
JsonValue revisionsJson = JsonUtils.from(jsonBuilder.json());
assertThat(revisionsJson.getString(0, "revision_href"), is("pipelines/" + revision));
}
use of com.thoughtworks.go.util.JsonValue in project gocd by gocd.
the class JobControllerTest method shouldFindTheLatestJobWhenJobStatusIsRequested.
@Test
public void shouldFindTheLatestJobWhenJobStatusIsRequested() throws Exception {
JobInstance job = JobInstanceMother.buildEndingWithState(JobState.Rescheduled, JobResult.Unknown, "config");
job.assign("agent", new Date());
JobInstance newJob = JobInstanceMother.buildEndingWithState(JobState.Building, JobResult.Unknown, "another_config");
newJob.setId(2);
newJob.assign("another_agent", new Date());
String pipelineName = job.getPipelineName();
String stageName = job.getStageName();
when(jobInstanceService.buildByIdWithTransitions(job.getId())).thenReturn(job);
when(jobDetailService.findMostRecentBuild(job.getIdentifier())).thenReturn(newJob);
when(stageService.getBuildDuration(pipelineName, stageName, newJob)).thenReturn(new DurationBean(newJob.getId(), 5l));
ModelAndView modelAndView = jobController.handleRequest(pipelineName, stageName, job.getId(), response);
verify(jobInstanceService).buildByIdWithTransitions(job.getId());
verify(jobDetailService).findMostRecentBuild(job.getIdentifier());
verify(stageService).getBuildDuration(pipelineName, stageName, newJob);
JsonValue json = from(((List) modelAndView.getModel().get("json")).get(0));
JsonValue buildingInfo = json.getObject("building_info");
assertThat(buildingInfo.getString("id"), is("2"));
assertThat(buildingInfo.getString("last_build_duration"), is("5"));
}
Aggregations