Search in sources :

Example 1 with StageResourceImporter

use of com.thoughtworks.studios.shine.cruise.stage.details.StageResourceImporter in project gocd by gocd.

the class ShineDaoIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    dbHelper.onSetUp();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    result = new SubsectionLocalizedOperationResult();
    File tempFolder = temporaryFolder.newFolder("artifacts");
    String artifactsRoot = tempFolder.getAbsolutePath();
    stageStorage.clear();
    StageResourceImporter importer = new StageResourceImporter(artifactsRoot, xmlApiService, stageService, pipelineHistoryService, systemEnvironment);
    LazyStageGraphLoader graphLoader = new LazyStageGraphLoader(importer, stageStorage);
    StagesQuery stagesQuery = new StagesQuery(graphLoader, stagesQueryCache);
    shineDao = new ShineDao(stagesQuery, stageService, pipelineHistoryService);
    goURLRepository = new StubGoURLRepository("http://localhost:8153", artifactsRoot);
    failureSetup = new TestFailureSetup(materialRepository, dbHelper, pipelineTimeline, configHelper, transactionTemplate);
    TestFailureSetup.SavedStage savedStage = failureSetup.setupPipelineInstance(true, null, goURLRepository);
    pipeline = savedStage.pipeline;
    stageId = savedStage.stageId;
}
Also used : StagesQuery(com.thoughtworks.studios.shine.cruise.stage.StagesQuery) StageResourceImporter(com.thoughtworks.studios.shine.cruise.stage.details.StageResourceImporter) SubsectionLocalizedOperationResult(com.thoughtworks.go.server.service.result.SubsectionLocalizedOperationResult) LazyStageGraphLoader(com.thoughtworks.studios.shine.cruise.stage.details.LazyStageGraphLoader) File(java.io.File) StubGoURLRepository(com.thoughtworks.studios.shine.net.StubGoURLRepository) Before(org.junit.Before)

Example 2 with StageResourceImporter

use of com.thoughtworks.studios.shine.cruise.stage.details.StageResourceImporter in project gocd by gocd.

the class BackgroundStageLoaderIntegrationTest method stageWithInvalidJobPropertiesShouldNotSaveStageToStageStorage.

@Test
public void stageWithInvalidJobPropertiesShouldNotSaveStageToStageStorage() {
    PropertiesService propertiesService = mock(PropertiesService.class);
    when(propertiesService.getPropertiesForJob(anyLong())).thenThrow(new RuntimeException("something bad happened"));
    xmlApiService = new XmlApiService(propertiesService, artifactsService, jobInstanceService, stageService);
    StageResourceImporter importer = new StageResourceImporter("/artifacts", xmlApiService, stageFinder, pipelineInstanceLoader, systemEnvironment);
    loader = new BackgroundStageLoader(null, importer, stageStorage, pipelineHistoryService, stageService, systemEnvironment);
    TestFailureSetup.SavedStage stage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
    try {
        loader.handle(feedEntry(stage), pipelineInstanceLoader);
        fail("should have failed as properties api bombed");
    } catch (Exception e) {
    // expected
    }
    assertFalse(stageStorage.isStageStored(stage.stageId));
}
Also used : StageResourceImporter(com.thoughtworks.studios.shine.cruise.stage.details.StageResourceImporter) TestFailureSetup(com.thoughtworks.go.server.dao.sparql.TestFailureSetup) Date(java.util.Date) Test(org.junit.Test)

Example 3 with StageResourceImporter

use of com.thoughtworks.studios.shine.cruise.stage.details.StageResourceImporter in project gocd by gocd.

the class BackgroundStageLoaderIntegrationTest method stageWithInvalidPipelineFeedShouldNotSaveStageToStageStorage.

@Test
public void stageWithInvalidPipelineFeedShouldNotSaveStageToStageStorage() {
    TestFailureSetup.SavedStage stage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
    pipelineInstanceLoader = mock(PipelineInstanceLoader.class);
    when(pipelineInstanceLoader.loadPipelineForShine(anyLong())).thenThrow(new RuntimeException("ouch, that hurt!"));
    StageResourceImporter importer = new StageResourceImporter("/artifacts", xmlApiService, stageFinder, pipelineInstanceLoader, systemEnvironment);
    loader = new BackgroundStageLoader(null, importer, stageStorage, pipelineHistoryService, stageService, systemEnvironment);
    try {
        loader.handle(feedEntry(stage), pipelineInstanceLoader);
        fail("should have failed as pipeline load bombed");
    } catch (Exception e) {
    // expected
    }
    assertFalse(stageStorage.isStageStored(stage.stageId));
}
Also used : StageResourceImporter(com.thoughtworks.studios.shine.cruise.stage.details.StageResourceImporter) TestFailureSetup(com.thoughtworks.go.server.dao.sparql.TestFailureSetup) Date(java.util.Date) Test(org.junit.Test)

Example 4 with StageResourceImporter

use of com.thoughtworks.studios.shine.cruise.stage.details.StageResourceImporter in project gocd by gocd.

the class BackgroundStageLoaderIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    dbHelper.onSetUp();
    File tempFolder = temporaryFolder.newFolder("shine");
    stageStorage = new StageStorage(tempFolder.getAbsolutePath());
    stageStorage.clear();
    stageFinder = stageService;
    pipelineInstanceLoader = pipelineHistoryService;
    StageResourceImporter importer = new StageResourceImporter("/artifacts", xmlApiService, stageFinder, pipelineInstanceLoader, systemEnvironment);
    loader = new BackgroundStageLoader(null, importer, stageStorage, pipelineHistoryService, stageService, systemEnvironment);
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    failureSetup = new TestFailureSetup(materialRepository, dbHelper, pipelineTimeline, configHelper, transactionTemplate);
}
Also used : StageResourceImporter(com.thoughtworks.studios.shine.cruise.stage.details.StageResourceImporter) TestFailureSetup(com.thoughtworks.go.server.dao.sparql.TestFailureSetup) StageStorage(com.thoughtworks.studios.shine.cruise.stage.details.StageStorage) File(java.io.File) Before(org.junit.Before)

Aggregations

StageResourceImporter (com.thoughtworks.studios.shine.cruise.stage.details.StageResourceImporter)4 TestFailureSetup (com.thoughtworks.go.server.dao.sparql.TestFailureSetup)3 File (java.io.File)2 Date (java.util.Date)2 Before (org.junit.Before)2 Test (org.junit.Test)2 SubsectionLocalizedOperationResult (com.thoughtworks.go.server.service.result.SubsectionLocalizedOperationResult)1 StagesQuery (com.thoughtworks.studios.shine.cruise.stage.StagesQuery)1 LazyStageGraphLoader (com.thoughtworks.studios.shine.cruise.stage.details.LazyStageGraphLoader)1 StageStorage (com.thoughtworks.studios.shine.cruise.stage.details.StageStorage)1 StubGoURLRepository (com.thoughtworks.studios.shine.net.StubGoURLRepository)1