Search in sources :

Example 1 with InstanceFactory

use of com.thoughtworks.go.server.service.InstanceFactory in project gocd by gocd.

the class PipelineWithRunOnAllJob method scheduleAndCompleteFollowingStages.

protected void scheduleAndCompleteFollowingStages(Pipeline pipeline, JobResult result) {
    Stage ft = new InstanceFactory().createStageInstance(ftStage(), new DefaultSchedulingContext("anyone"), "md5-test", new TimeProvider());
    ft.setOrderId(pipeline.getFirstStage().getOrderId() + 1);
    dbHelper.getStageDao().saveWithJobs(pipeline, ft);
    dbHelper.completeStage(ft, result);
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory) Stage(com.thoughtworks.go.domain.Stage) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Example 2 with InstanceFactory

use of com.thoughtworks.go.server.service.InstanceFactory in project gocd by gocd.

the class IsSecurityEnabledVoterTest method shouldNotVoteAccessGrantedIfSecurityIsEnabledButAnonymousIsNot.

@Test
public void shouldNotVoteAccessGrantedIfSecurityIsEnabledButAnonymousIsNot() {
    configHelper.addBogusSecurity(false);
    GoConfigService configService = new GoConfigService(goConfigDao, null, new SystemTimeClock(), mock(GoConfigMigration.class), null, null, ConfigElementImplementationRegistryMother.withNoPlugins(), new InstanceFactory(), mock(CachedGoPartials.class), null);
    IsSecurityEnabledVoter voter = new IsSecurityEnabledVoter(configService);
    int accessStatus = voter.vote(null, null, null);
    assertThat(accessStatus, Is.is(AccessDecisionVoter.ACCESS_ABSTAIN));
}
Also used : CachedGoPartials(com.thoughtworks.go.config.CachedGoPartials) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory) SystemTimeClock(com.thoughtworks.go.util.SystemTimeClock) GoConfigMigration(com.thoughtworks.go.config.GoConfigMigration) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) Test(org.junit.Test)

Example 3 with InstanceFactory

use of com.thoughtworks.go.server.service.InstanceFactory in project gocd by gocd.

the class PipelineWithMultipleStages method scheduleAndCompleteFollowingStages.

@Override
protected void scheduleAndCompleteFollowingStages(Pipeline pipeline, JobResult result) {
    for (int index = 2; index <= stagesSize; index++) {
        StageConfig stageConfig = stageConfig(index);
        Stage instance = new InstanceFactory().createStageInstance(stageConfig, new DefaultSchedulingContext("anyone"), "md5-test", new TimeProvider());
        instance.setOrderId(index);
        dbHelper.getStageDao().saveWithJobs(pipeline, instance);
        dbHelper.completeStage(instance, result);
    }
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory) Stage(com.thoughtworks.go.domain.Stage) StageConfig(com.thoughtworks.go.config.StageConfig) DefaultSchedulingContext(com.thoughtworks.go.domain.DefaultSchedulingContext)

Example 4 with InstanceFactory

use of com.thoughtworks.go.server.service.InstanceFactory in project gocd by gocd.

the class PipelineHistoryMother method stageHistory.

public static StageInstanceModels stageHistory(PipelineConfig pipelineConfig, Date modificationDate) {
    StageInstanceModels history = new StageInstanceModels();
    for (StageConfig stageConfig : pipelineConfig) {
        StageInstanceModel item = new StageInstanceModel(str(stageConfig.name()), "1", buildHistory(stageConfig, modificationDate));
        item.setCounter("1");
        item.setApprovalType(new InstanceFactory().createStageInstance(stageConfig, new DefaultSchedulingContext("anyone"), md5, new TimeProvider()).getApprovalType());
        if (stageConfig.requiresApproval()) {
            item.setApprovedBy(APPROVED_BY);
        } else {
            item.setApprovedBy(GoConstants.DEFAULT_APPROVED_BY);
        }
        history.add(item);
    }
    return history;
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory) StageConfig(com.thoughtworks.go.config.StageConfig)

Example 5 with InstanceFactory

use of com.thoughtworks.go.server.service.InstanceFactory in project gocd by gocd.

the class StageMother method scheduleInstance.

private static Stage scheduleInstance(StageConfig stageConfig) {
    Stage stageInstance = new InstanceFactory().createStageInstance(stageConfig, new DefaultSchedulingContext(DEFAULT_APPROVED_BY), "md5-test", new TimeProvider());
    stageInstance.building();
    return stageInstance;
}
Also used : TimeProvider(com.thoughtworks.go.util.TimeProvider) InstanceFactory(com.thoughtworks.go.server.service.InstanceFactory)

Aggregations

InstanceFactory (com.thoughtworks.go.server.service.InstanceFactory)6 TimeProvider (com.thoughtworks.go.util.TimeProvider)5 StageConfig (com.thoughtworks.go.config.StageConfig)2 DefaultSchedulingContext (com.thoughtworks.go.domain.DefaultSchedulingContext)2 Stage (com.thoughtworks.go.domain.Stage)2 CachedGoPartials (com.thoughtworks.go.config.CachedGoPartials)1 GoConfigMigration (com.thoughtworks.go.config.GoConfigMigration)1 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)1 SystemTimeClock (com.thoughtworks.go.util.SystemTimeClock)1 Test (org.junit.Test)1