use of com.thoughtworks.go.server.domain.Username in project gocd by gocd.
the class GoConfigServiceTest method badConfigShouldContainOldMD5_WhenConfigUpdateFailed.
@Test
public void badConfigShouldContainOldMD5_WhenConfigUpdateFailed() {
when(goConfigDao.updateConfig(org.mockito.Matchers.<UpdateConfigCommand>any())).thenThrow(new RuntimeException(getGoConfigInvalidException()));
ConfigUpdateResponse configUpdateResponse = goConfigService.updateConfigFromUI(mock(UpdateConfigFromUI.class), "old-md5", new Username(new CaseInsensitiveString("user")), new HttpLocalizedOperationResult());
assertThat(configUpdateResponse.wasMerged(), is(false));
assertThat(configUpdateResponse.getCruiseConfig().getMd5(), is("old-md5"));
}
use of com.thoughtworks.go.server.domain.Username in project gocd by gocd.
the class GoDashboardServiceTest method allPipelineGroupsForDashboard_shouldRetrievePipelineGroupsBasedOnUsersPipelineSelections.
@Test
public void allPipelineGroupsForDashboard_shouldRetrievePipelineGroupsBasedOnUsersPipelineSelections() throws Exception {
PipelineSelections pipelineSelections = mock(PipelineSelections.class);
configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1");
GoDashboardPipeline pipeline1 = pipeline("pipeline1", "group1", new Permissions(new AllowedUsers(Collections.singleton("user1"), Collections.emptySet()), NoOne.INSTANCE, NoOne.INSTANCE, NoOne.INSTANCE));
configMother.addPipelineWithGroup(config, "group2", "pipeline2", "stage1A", "job1A1");
GoDashboardPipeline pipeline2 = pipeline("pipeline2", "group2", new Permissions(NoOne.INSTANCE, NoOne.INSTANCE, NoOne.INSTANCE, NoOne.INSTANCE));
addPipelinesToCache(pipeline1, pipeline2);
when(pipelineSelections.includesPipeline(any(PipelineConfig.class))).thenReturn(true);
List<GoDashboardPipelineGroup> pipelineGroups = allPipelineGroupsForDashboard(pipelineSelections, new Username("user1"));
assertThat(pipelineGroups.size(), is(1));
assertThat(pipelineGroups.get(0).allPipelineNames(), contains("pipeline1"));
assertThat(pipelineGroups.get(0).allPipelines(), contains(pipeline1));
}
use of com.thoughtworks.go.server.domain.Username in project gocd by gocd.
the class GoDashboardServiceTest method allPipelineGroupsForDashboard_shouldRetrieveTheLatestKnownSetOfPipelinesFromTheCache.
@Test
public void allPipelineGroupsForDashboard_shouldRetrieveTheLatestKnownSetOfPipelinesFromTheCache() throws Exception {
PipelineSelections pipelineSelections = mock(PipelineSelections.class);
configMother.addPipelineWithGroup(config, "group1", "pipeline2", "stage1A", "job1A1");
GoDashboardPipeline pipeline2 = pipeline("pipeline2", "group1");
configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1");
GoDashboardPipeline pipeline1 = pipeline("pipeline1", "group1");
addPipelinesToCache(pipeline1, pipeline2);
when(pipelineSelections.includesPipeline(any(PipelineConfig.class))).thenReturn(true);
List<GoDashboardPipelineGroup> pipelineGroups = allPipelineGroupsForDashboard(pipelineSelections, new Username("user1"));
assertThat(pipelineGroups.size(), is(1));
assertThat(pipelineGroups.get(0).allPipelineNames(), contains("pipeline1", "pipeline2"));
assertThat(pipelineGroups.get(0).allPipelines(), contains(pipeline1, pipeline2));
}
use of com.thoughtworks.go.server.domain.Username in project gocd by gocd.
the class GoDashboardServiceTest method allPipelineGroupsForDashboard_shouldNotListPipelinesExistingInConfigButNotInCache.
@Test
public void allPipelineGroupsForDashboard_shouldNotListPipelinesExistingInConfigButNotInCache() throws Exception {
PipelineSelections pipelineSelections = mock(PipelineSelections.class);
configMother.addPipelineWithGroup(config, "group1", "pipeline2", "stage1A", "job1A1");
configMother.addPipelineWithGroup(config, "group1", "pipeline1", "stage1A", "job1A1");
GoDashboardPipeline pipeline1 = pipeline("pipeline1", "group1", new Permissions(Everyone.INSTANCE, Everyone.INSTANCE, Everyone.INSTANCE, Everyone.INSTANCE));
addPipelinesToCache(pipeline1);
when(pipelineSelections.includesPipeline(any(PipelineConfig.class))).thenReturn(true);
List<GoDashboardPipelineGroup> pipelineGroups = allPipelineGroupsForDashboard(pipelineSelections, new Username("user1"));
assertThat(pipelineGroups.size(), is(1));
assertThat(pipelineGroups.get(0).allPipelineNames(), contains("pipeline1"));
assertThat(pipelineGroups.get(0).allPipelines(), contains(pipeline1));
}
use of com.thoughtworks.go.server.domain.Username 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)));
}
Aggregations