Search in sources :

Example 1 with JobStateTransition

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()));
    }
}
Also used : JobStateTransition(com.thoughtworks.go.domain.JobStateTransition)

Example 2 with JobStateTransition

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())));
    }
}
Also used : JobStateTransition(com.thoughtworks.go.domain.JobStateTransition)

Example 3 with JobStateTransition

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);
        }
    });
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) JobInstance(com.thoughtworks.go.domain.JobInstance) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) TransactionStatus(org.springframework.transaction.TransactionStatus) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Pipeline(com.thoughtworks.go.domain.Pipeline) JobStateTransition(com.thoughtworks.go.domain.JobStateTransition) TransactionCallback(org.springframework.transaction.support.TransactionCallback) Username(com.thoughtworks.go.server.domain.Username) Stage(com.thoughtworks.go.domain.Stage) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Aggregations

JobStateTransition (com.thoughtworks.go.domain.JobStateTransition)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 JobInstance (com.thoughtworks.go.domain.JobInstance)1 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)1 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 Pipeline (com.thoughtworks.go.domain.Pipeline)1 Stage (com.thoughtworks.go.domain.Stage)1 Modification (com.thoughtworks.go.domain.materials.Modification)1 Username (com.thoughtworks.go.server.domain.Username)1 TransactionStatus (org.springframework.transaction.TransactionStatus)1 TransactionCallback (org.springframework.transaction.support.TransactionCallback)1