Search in sources :

Example 51 with Username

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"));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) ConfigUpdateResponse(com.thoughtworks.go.config.update.ConfigUpdateResponse) UpdateConfigFromUI(com.thoughtworks.go.config.update.UpdateConfigFromUI) Test(org.junit.Test)

Example 52 with Username

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));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Username(com.thoughtworks.go.server.domain.Username) AllowedUsers(com.thoughtworks.go.config.security.users.AllowedUsers) Permissions(com.thoughtworks.go.config.security.Permissions) Test(org.junit.Test)

Example 53 with Username

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));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.Test)

Example 54 with Username

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));
}
Also used : PipelineSelections(com.thoughtworks.go.server.domain.user.PipelineSelections) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Username(com.thoughtworks.go.server.domain.Username) Permissions(com.thoughtworks.go.config.security.Permissions) Test(org.junit.Test)

Example 55 with Username

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)));
}
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)

Aggregations

Username (com.thoughtworks.go.server.domain.Username)391 Test (org.junit.Test)317 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)170 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)81 Before (org.junit.Before)42 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)36 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)33 Pipeline (com.thoughtworks.go.domain.Pipeline)30 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)27 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)21 StringContains.containsString (org.hamcrest.core.StringContains.containsString)20 Modification (com.thoughtworks.go.domain.materials.Modification)17 ArrayList (java.util.ArrayList)16 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)15 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)14 TimeProvider (com.thoughtworks.go.util.TimeProvider)13 UpdateConfigFromUI (com.thoughtworks.go.config.update.UpdateConfigFromUI)12 Date (java.util.Date)12 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)11 ConfigUpdateResponse (com.thoughtworks.go.config.update.ConfigUpdateResponse)10