Search in sources :

Example 1 with ScheduleTestUtil

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

the class PipelineRepositoryIntegrationTest method shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations.

@Test
public void shouldConsider_firstRevision_forAFlyweight_asInDb_whilePickingFromMultipleDeclarations() {
    ScheduleTestUtil u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
    int i = 1;
    GitMaterial git1 = u.wf(new GitMaterial("git"), "folder1");
    u.checkinInOrder(git1, "g1");
    GitMaterial git2 = u.wf(new GitMaterial("git"), "folder2");
    ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("P", u.m(git1), u.m(git2));
    CruiseConfig cruiseConfig = goConfigDao.load();
    u.checkinInOrder(git1, u.d(i++), "g2");
    u.runAndPass(p, "g1", "g2");
    u.runAndPass(p, "g2", "g1");
    PipelineTimeline timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    timeline.updateTimelineOnInit();
    List<PipelineTimelineEntry> timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
    assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
    assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
    List<PipelineTimelineEntry.Revision> flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g1"));
    assertThat(flyweightsRevs.get(1).revision, is("g2"));
    assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
    assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
    flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g2"));
    assertThat(flyweightsRevs.get(1).revision, is("g1"));
    MaterialConfigs materials = configHelper.deepClone(p.config.materialConfigs());
    Collections.reverse(materials);
    configHelper.setMaterialConfigForPipeline("P", materials.toArray(new MaterialConfig[0]));
    goConfigDao.load();
    timeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    timeline.updateTimelineOnInit();
    timelineEntries = new ArrayList<>(timeline.getEntriesFor("P"));
    assertThat(timelineEntries.get(0).getPipelineLocator().getCounter(), is(1));
    assertThat(timelineEntries.get(0).naturalOrder(), is(1.0));
    flyweightsRevs = new ArrayList<>(timelineEntries.get(0).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g1"));
    assertThat(flyweightsRevs.get(1).revision, is("g2"));
    assertThat(timelineEntries.get(1).getPipelineLocator().getCounter(), is(2));
    assertThat(timelineEntries.get(1).naturalOrder(), is(2.0));
    flyweightsRevs = new ArrayList<>(timelineEntries.get(1).revisions().values()).get(0);
    assertThat(flyweightsRevs.get(0).revision, is("g2"));
    assertThat(flyweightsRevs.get(1).revision, is("g1"));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) Test(org.junit.jupiter.api.Test)

Example 2 with ScheduleTestUtil

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

the class StageSqlMapDaoIntegrationTest method setup.

@BeforeEach
public void setup() throws Exception {
    goCache.clear();
    dbHelper.onSetUp();
    mingleConfig = twoBuildPlansWithResourcesAndMaterials(PIPELINE_NAME, STAGE_DEV);
    origTemplate = stageDao.getSqlMapClientTemplate();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    scheduleUtil = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
}
Also used : ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ScheduleTestUtil

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

the class DownstreamInstancePopulatorIntegrationTest method setup.

@BeforeEach
public void setup() throws Exception {
    configHelper = new GoConfigFileHelper();
    goCache.clear();
    configHelper.usingCruiseConfigDao(goConfigDao);
    configHelper.onSetUp();
    dbHelper.onSetUp();
    u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
    downstreamInstancePopulator = new DownstreamInstancePopulator(pipelineDao);
    notifier.disableUpdates();
}
Also used : GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 4 with ScheduleTestUtil

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

the class MaterialRepositoryIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    originalTemplate = repo.getHibernateTemplate();
    dbHelper.onSetUp();
    goCache.clear();
    u = new ScheduleTestUtil(transactionTemplate, repo, dbHelper, new GoConfigFileHelper());
}
Also used : ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) Before(org.junit.Before)

Example 5 with ScheduleTestUtil

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

the class PipelineSqlMapDaoIntegrationTest method setup.

@BeforeEach
public void setup() throws Exception {
    dbHelper.onSetUp();
    goCache.clear();
    configHelper = new GoConfigFileHelper();
    configHelper.usingCruiseConfigDao(goConfigDao);
    u = new ScheduleTestUtil(transactionTemplate, materialRepository, dbHelper, configHelper);
    notifier.disableUpdates();
}
Also used : GoConfigFileHelper(com.thoughtworks.go.util.GoConfigFileHelper) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)5 BeforeEach (org.junit.jupiter.api.BeforeEach)3 GoConfigFileHelper (com.thoughtworks.go.util.GoConfigFileHelper)2 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)1 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)1 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)1 PipelineTimeline (com.thoughtworks.go.server.domain.PipelineTimeline)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1