use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class DependencyMaterialInstance method toOldMaterial.
@Override
public Material toOldMaterial(String name, String folder, String password) {
DependencyMaterial dep = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(stageName));
setName(name, dep);
dep.setId(id);
return dep;
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class PipelineSqlMapDaoCachingTest method shouldNotInvalidateCacheOfPipelineInstancesTriggeredWithDependencyMaterial_WhenADifferentPipelineInstanceIsCreatedWithDifferentRevision.
@Test
public void shouldNotInvalidateCacheOfPipelineInstancesTriggeredWithDependencyMaterial_WhenADifferentPipelineInstanceIsCreatedWithDifferentRevision() throws Exception {
String cacheKey = (PipelineSqlMapDao.class + "_cacheKeyForPipelineInstancesWithDependencyMaterial_" + "p1_p_1").intern();
List<PipelineIdentifier> result = Arrays.asList(new PipelineIdentifier("p1", 1, "1"));
when(mockTemplate.queryForList(eq("pipelineInstancesTriggeredOutOfDependencyMaterial"), anyString())).thenReturn(result);
List<PipelineIdentifier> actual = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial("p1", new PipelineIdentifier("p", 1));
assertThat(actual, Matchers.is(result));
assertThat(goCache.get(cacheKey), is(result));
MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(new DependencyMaterial(new CaseInsensitiveString("p"), new CaseInsensitiveString("s")), new Modification("u", "comment", "email", new Date(), "p/2/s/1")));
Pipeline pipeline = new Pipeline("p1", BuildCause.createWithModifications(materialRevisions, ""));
pipelineDao.save(pipeline);
assertThat(goCache.get(cacheKey), is(result));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class PipelineSqlMapDaoCachingTest method loadActivePipelines_shouldCacheResult.
@Test
public void loadActivePipelines_shouldCacheResult() {
final String pipelineName = "pipeline";
CruiseConfig mockCruiseConfig = mock(BasicCruiseConfig.class);
GoConfigDao mockconfigFileDao = mock(GoConfigDao.class);
when(mockconfigFileDao.load()).thenReturn(mockCruiseConfig);
when(mockCruiseConfig.getAllPipelineNames()).thenReturn(Arrays.asList(new CaseInsensitiveString(pipelineName)));
// need to mock configfileDao for this test
pipelineDao = new PipelineSqlMapDao(null, repository, goCache, environmentVariableDao, transactionTemplate, null, transactionSynchronizationManager, null, mockconfigFileDao, null, mock(SessionFactory.class));
pipelineDao.setSqlMapClientTemplate(mockTemplate);
PipelineInstanceModel pipeline = new PipelineInstanceModel(pipelineName, -2, "label", BuildCause.createManualForced(), new StageInstanceModels());
PipelineInstanceModels pims = PipelineInstanceModels.createPipelineInstanceModels(pipeline);
when(mockTemplate.queryForList("allActivePipelines")).thenReturn(pims);
when(mockTemplate.queryForObject(eq("getPipelineHistoryById"), any())).thenReturn(pipeline);
PipelineInstanceModels loaded;
loaded = pipelineDao.loadActivePipelines();
loaded = pipelineDao.loadActivePipelines();
assertNotSame(pipeline, loaded);
assertTrue(ToStringBuilder.reflectionToString(loaded) + " not equal to\n" + ToStringBuilder.reflectionToString(pipeline), EqualsBuilder.reflectionEquals(loaded, pims));
verify(mockTemplate, times(1)).queryForList("allActivePipelines");
verify(mockTemplate, times(1)).queryForObject(eq("getPipelineHistoryById"), any());
verify(mockconfigFileDao, times(2)).load();
verify(mockCruiseConfig, times(2)).getAllPipelineNames();
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class PipelineSqlMapDaoCachingTest method shouldInvalidateCacheOfPipelineInstancesTriggeredWithDependencyMaterial.
@Test
public void shouldInvalidateCacheOfPipelineInstancesTriggeredWithDependencyMaterial() throws Exception {
String cacheKey = (PipelineSqlMapDao.class + "_cacheKeyForPipelineInstancesWithDependencyMaterial_" + "p1_p_1").intern();
List<PipelineIdentifier> result = Arrays.asList(new PipelineIdentifier("p1", 1, "1"));
when(mockTemplate.queryForList(eq("pipelineInstancesTriggeredOutOfDependencyMaterial"), anyString())).thenReturn(new ArrayList());
List<PipelineIdentifier> actual = pipelineDao.getPipelineInstancesTriggeredWithDependencyMaterial("p1", new PipelineIdentifier("p", 1));
assertThat(actual, hasSize(0));
assertThat((List<PipelineIdentifier>) goCache.get(cacheKey), hasSize(0));
MaterialRevisions materialRevisions = new MaterialRevisions(new MaterialRevision(new DependencyMaterial(new CaseInsensitiveString("p"), new CaseInsensitiveString("s")), new Modification("u", "comment", "email", new Date(), "p/1/s/1")));
Pipeline pipeline = new Pipeline("p1", BuildCause.createWithModifications(materialRevisions, ""));
doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((TransactionSynchronizationAdapter) invocation.getArguments()[0]).afterCommit();
return null;
}
}).when(transactionSynchronizationManager).registerSynchronization(any(TransactionSynchronization.class));
when(transactionTemplate.execute(any(TransactionCallback.class))).then(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
((TransactionCallback) invocation.getArguments()[0]).doInTransaction(new SimpleTransactionStatus());
return null;
}
});
pipelineDao.save(pipeline);
assertThat(goCache.get(cacheKey), is(Matchers.nullValue()));
}
use of com.thoughtworks.go.config.CaseInsensitiveString in project gocd by gocd.
the class GoDashboardPipelineLockStatusChangeHandlerTest method shouldHandlePipelineLockStatusChangeByRefreshingPipelineInCache.
@Test
public void shouldHandlePipelineLockStatusChangeByRefreshingPipelineInCache() throws Exception {
handler.call(PipelineLockStatusChangeListener.Event.lock("pipeline1"));
verify(cacheUpdateService).updateCacheForPipeline(new CaseInsensitiveString("pipeline1"));
}
Aggregations