Search in sources :

Example 66 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class JobInstanceServiceTest method shouldDelegateToDAO_findJobHistoryPage.

@Test
public void shouldDelegateToDAO_findJobHistoryPage() {
    when(cruiseConfig.hasPipelineNamed(new CaseInsensitiveString("pipeline"))).thenReturn(true);
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(securityService.hasViewPermissionForPipeline(Username.valueOf("looser"), "pipeline")).thenReturn(true);
    final JobInstanceService jobService = new JobInstanceService(jobInstanceDao, buildPropertiesService, topic, jobStatusCache, transactionTemplate, transactionSynchronizationManager, null, null, goConfigService, securityService, pluginManager, serverHealthService);
    Pagination pagination = Pagination.pageStartingAt(1, 1, 1);
    jobService.findJobHistoryPage("pipeline", "stage", "job", pagination, "looser", new HttpOperationResult());
    verify(jobInstanceDao).findJobHistoryPage("pipeline", "stage", "job", pagination.getPageSize(), pagination.getOffset());
}
Also used : Pagination(com.thoughtworks.go.server.util.Pagination) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 67 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class ManualBuildTest method setUp.

@Before
public void setUp() {
    manualBuild = new ManualBuild(new Username(new CaseInsensitiveString("cruise-user")));
    SvnMaterial material = new SvnMaterial("http://foo.bar/baz", "user", "pass", false);
    materialRevisions = new MaterialRevisions(new MaterialRevision(material, new Modification(new Date(), "1234", "MOCK_LABEL-12", null)));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Username(com.thoughtworks.go.server.domain.Username) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Before(org.junit.Before)

Example 68 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class StageStatusPluginNotifierTest method shouldNotifyInterestedPluginsIfStageStateIsScheduled.

@Test
public void shouldNotifyInterestedPluginsIfStageStateIsScheduled() throws Exception {
    when(notificationPluginRegistry.isAnyPluginInterestedIn(NotificationExtension.STAGE_STATUS_CHANGE_NOTIFICATION)).thenReturn(true);
    when(stage.isScheduled()).thenReturn(true);
    when(stage.isReRun()).thenReturn(false);
    when(stage.getState()).thenReturn(StageState.Unknown);
    String pipelineName = "pipeline-name";
    when(stage.getIdentifier()).thenReturn(new StageIdentifier(pipelineName, 1, "stage", "1"));
    when(goConfigService.findGroupNameByPipeline(new CaseInsensitiveString(pipelineName))).thenReturn("group1");
    when(pipelineSqlMapDao.findBuildCauseOfPipelineByNameAndCounter(pipelineName, stage.getIdentifier().getPipelineCounter())).thenReturn(BuildCause.createManualForced());
    stageStatusPluginNotifier.stageStatusChanged(stage);
    verify(pluginNotificationQueue).post(captor.capture());
    assertThat(captor.getValue().getData() instanceof StageNotificationData, is(true));
    StageNotificationData data = (StageNotificationData) captor.getValue().getData();
    assertThat(data.getStage(), is(stage));
    assertThat(data.getBuildCause(), is(BuildCause.createManualForced()));
    assertThat(data.getPipelineGroup(), is("group1"));
}
Also used : CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageNotificationData(com.thoughtworks.go.domain.notificationdata.StageNotificationData) Test(org.junit.Test)

Example 69 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class PipelineRepositoryTest method shouldNotUpdateTimelineEntriesAndEntriesForRollbackUponFailureDuringRetrieval.

@Test
public void shouldNotUpdateTimelineEntriesAndEntriesForRollbackUponFailureDuringRetrieval() throws Exception {
    Object[] pipelineRow1 = { "p1", new BigInteger("1"), new BigInteger("1"), new Date(), "fingerprint", 1.0, "r1", null, new BigInteger("1"), new BigInteger("1") };
    Object[] pipelineRow2 = { "p1", "cause-failure-during-retrieval", new BigInteger("2"), new Date(), "fingerprint", 2.0, "r2", null, new BigInteger("1"), new BigInteger("1") };
    stubPipelineInstancesInDb(pipelineRow1, pipelineRow2);
    ArrayList<PipelineTimelineEntry> tempEntries = new ArrayList<>();
    PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    try {
        pipelineRepository.updatePipelineTimeline(pipelineTimeline, tempEntries);
        fail("Should fail to retrieve pipeline.");
    } catch (ClassCastException e) {
        assertThat(tempEntries.size(), is(0));
        assertThat(pipelineTimeline.instanceCount(new CaseInsensitiveString("p1")), is(0));
    }
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 70 with CaseInsensitiveString

use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.

the class PipelineRepositoryTest method shouldUpdateTimelineEntriesAndEntriesForRollbackDuringFailureWhileUpdatingTheDb.

@Test
public void shouldUpdateTimelineEntriesAndEntriesForRollbackDuringFailureWhileUpdatingTheDb() throws Exception {
    Object[] pipelineRow1 = { "p1", new BigInteger("1"), new BigInteger("1"), new Date(), "fingerprint", 1.0, "r1", null, new BigInteger("1"), new BigInteger("1") };
    Object[] pipelineRow2 = { "p1", new BigInteger("2"), new BigInteger("2"), new Date(), "fingerprint", 2.0, "r2", null, new BigInteger("1"), new BigInteger("1") };
    stubPipelineInstancesInDb(pipelineRow1, pipelineRow2);
    when(sqlQuery.executeUpdate()).thenThrow(new RuntimeException("Failure during update natural order in db"));
    ArrayList<PipelineTimelineEntry> tempEntries = new ArrayList<>();
    PipelineTimeline pipelineTimeline = new PipelineTimeline(pipelineRepository, transactionTemplate, transactionSynchronizationManager);
    try {
        pipelineRepository.updatePipelineTimeline(pipelineTimeline, tempEntries);
    } catch (RuntimeException e) {
        PipelineTimelineEntry timelineEntry1 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 1);
        PipelineTimelineEntry timelineEntry2 = pipelineTimeline.getEntryFor(new CaseInsensitiveString("p1"), 2);
        assertThat(pipelineTimeline.instanceCount(new CaseInsensitiveString("p1")), is(2));
        assertNotNull(timelineEntry1);
        assertNotNull(timelineEntry2);
        assertThat(tempEntries.size(), is(2));
        assertThat(tempEntries, containsInAnyOrder(timelineEntry1, timelineEntry2));
    }
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) PipelineTimelineEntry(com.thoughtworks.go.domain.PipelineTimelineEntry) PipelineTimeline(com.thoughtworks.go.server.domain.PipelineTimeline) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)392 Test (org.junit.Test)277 Username (com.thoughtworks.go.server.domain.Username)80 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)65 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)65 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)57 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)56 Date (java.util.Date)50 Modification (com.thoughtworks.go.domain.materials.Modification)44 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)30 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)28 Before (org.junit.Before)28 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)27 HashMap (java.util.HashMap)26 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)24 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)24 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)19 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)19 ArrayList (java.util.ArrayList)19 Pipeline (com.thoughtworks.go.domain.Pipeline)18