use of com.thoughtworks.go.domain.JobStateTransition in project gocd by gocd.
the class AssertHelper method assertTransitions.
private static void assertTransitions(JobStateTransitions actual, JobStateTransitions expect) {
String msg = "BuildStateTransitions should match";
nullsafeAssert(msg, actual, expect);
assertThat(actual.size(), is(expect.size()));
for (JobStateTransition expectTransition : expect) {
JobStateTransition actualTransition = actual.byState(expectTransition.getCurrentState());
assertThat(msg, actualTransition, is(not(nullValue())));
assertThat(msg, actualTransition.getStateChangeTime(), is(expectTransition.getStateChangeTime()));
}
}
use of com.thoughtworks.go.domain.JobStateTransition in project gocd by gocd.
the class GoPropertiesTestTest method assertCommonBuildProperties.
private void assertCommonBuildProperties(Pipeline newPipeline, JobInstance job) {
assertThat(propertyDao.value(job.getId(), GoConstants.CRUISE_PIPELINE_LABEL), is(newPipeline.getLabel()));
assertThat(propertyDao.value(job.getId(), GoConstants.CRUISE_PIPELINE_COUNTER), is(String.valueOf(newPipeline.getCounter())));
assertThat(propertyDao.value(job.getId(), GoConstants.CRUISE_JOB_DURATION), is(job.getCurrentBuildDuration()));
assertThat(propertyDao.value(job.getId(), GoConstants.CRUISE_RESULT), is(job.getResult().toString()));
assertThat(propertyDao.value(job.getId(), GoConstants.CRUISE_STAGE_COUNTER), is(job.getStageCounter()));
for (JobStateTransition transition : job.getTransitions()) {
String transitionKey = PropertiesService.getTransitionKey(transition.getCurrentState());
assertThat(propertyDao.value(job.getId(), transitionKey), is(DateUtils.formatISO8601(transition.getStateChangeTime())));
}
}
use of com.thoughtworks.go.domain.JobStateTransition in project gocd by gocd.
the class TestFailureSetup method setupPipelineInstnace.
private SavedStage setupPipelineInstnace(final boolean failStage, final String overriddenLabel, final List<Modification> modifications, final TestResultsStubbing test, final Date latestTransitionDate) {
return (SavedStage) transactionTemplate.execute(new TransactionCallback() {
public Object doInTransaction(TransactionStatus status) {
MaterialInstance materialInstance = materialRepository.findOrCreateFrom(hgMaterial);
for (Modification mod : modifications) {
mod.setMaterialInstance(materialInstance);
}
MaterialRevision rev = new MaterialRevision(hgMaterial, modifications);
materialRepository.saveMaterialRevision(rev);
Pipeline pipeline = PipelineMother.schedule(pipelineConfig, BuildCause.createManualForced(new MaterialRevisions(rev), new Username(new CaseInsensitiveString("loser"))));
if (overriddenLabel != null) {
pipeline.setLabel(overriddenLabel);
}
for (JobInstance instance : pipeline.getStages().get(0).getJobInstances()) {
for (JobStateTransition jobStateTransition : instance.getTransitions()) {
jobStateTransition.setStateChangeTime(latestTransitionDate);
}
}
dbHelper.save(pipeline);
Stage barStage = pipeline.getFirstStage();
if (failStage) {
dbHelper.failStage(barStage, latestTransitionDate);
}
test.stub(barStage);
pipelineTimeline.update();
return new SavedStage(pipeline);
}
});
}
Aggregations