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());
}
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)));
}
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"));
}
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));
}
}
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));
}
}
Aggregations