Search in sources :

Example 16 with HttpLocalizedOperationResult

use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.

the class ScheduleServiceTest method shouldCancelStageUsingPipelineNameAndStageName.

@Test
public void shouldCancelStageUsingPipelineNameAndStageName() throws Exception {
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    String pipelineName = "pipeline-name";
    Username admin = new Username(new CaseInsensitiveString("admin"));
    String stageName = "mingle";
    Pipeline pipeline = PipelineMother.pipeline(pipelineName, StageMother.passedStageInstance(stageName, "job-bar", pipelineName));
    Stage firstStage = pipeline.getFirstStage();
    long stageId = firstStage.getId();
    when(stageService.findLatestStage(pipelineName, stageName)).thenReturn(firstStage);
    ScheduleService spyedService = spy(service);
    doReturn(firstStage).when(spyedService).cancelAndTriggerRelevantStages(stageId, admin, result);
    Stage resultStage = spyedService.cancelAndTriggerRelevantStages(pipelineName, stageName, admin, result);
    assertThat(resultStage, is(firstStage));
    assertThat(result.httpCode(), is(SC_OK));
    assertThat(result.isSuccessful(), is(true));
    verify(stageService).findLatestStage(pipelineName, stageName);
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.Test)

Example 17 with HttpLocalizedOperationResult

use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.

the class ValueStreamMapServiceTest method setUp.

@Before
public void setUp() throws Exception {
    initMocks(this);
    user = new Username(new CaseInsensitiveString("poovan"));
    setupExistenceOfPipelines("p1", "p2", "p3", "MYPIPELINE");
    setupViewPermissionForPipelines("C", "A", "B", "P1", "P2", "P3", "p1", "p2", "p3", "MYPIPELINE");
    setupViewPermissionForGroups("g1");
    valueStreamMapService = new ValueStreamMapService(pipelineService, materialRepository, goConfigService, downstreaminstancepopulator, runStagesPopulator, unrunStagesPopulator, securityService);
    result = new HttpLocalizedOperationResult();
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Username(com.thoughtworks.go.server.domain.Username) Before(org.junit.Before)

Example 18 with HttpLocalizedOperationResult

use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.

the class VersionInfoServiceTest method shouldUpdateLatestVersion.

@Test
public void shouldUpdateLatestVersion() {
    ServerVersionInfoManager versionInfoManager = mock(ServerVersionInfoManager.class);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    new VersionInfoService(versionInfoManager).updateServerLatestVersion("16.1.0-123", result);
    verify(versionInfoManager).updateLatestVersion("16.1.0-123");
    assertTrue(result.isSuccessful());
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Test(org.junit.Test)

Example 19 with HttpLocalizedOperationResult

use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.

the class UserServiceTest method shouldCreateNewUsers.

@Test
public void shouldCreateNewUsers() throws Exception {
    UserSearchModel foo = new UserSearchModel(new User("fooUser", "Mr Foo", "foo@cruise.com"), UserSourceType.LDAP);
    doNothing().when(userDao).saveOrUpdate(foo.getUser());
    when(userDao.findUser("fooUser")).thenReturn(new NullUser());
    when(userDao.enabledUserCount()).thenReturn(10);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    userService.create(Arrays.asList(foo), result);
    assertThat(result.isSuccessful(), is(true));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) UserSearchModel(com.thoughtworks.go.presentation.UserSearchModel) Test(org.junit.Test)

Example 20 with HttpLocalizedOperationResult

use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.

the class UserServiceTest method shouldReturnErrorMessageWhenTheLastAdminIsBeingDisabled.

@Test
public void shouldReturnErrorMessageWhenTheLastAdminIsBeingDisabled() throws Exception {
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    when(userDao.enabledUsers()).thenReturn(Arrays.asList(new User("Jake"), new User("Pavan"), new User("Shilpa")));
    configureAdmin("Jake", true);
    configureAdmin("Pavan", true);
    configureAdmin("Shilpa", false);
    userService.disable(Arrays.asList("Pavan", "Jake"), result);
    assertThat(result.isSuccessful(), is(false));
    assertThat(result.httpCode(), is(HttpServletResponse.SC_BAD_REQUEST));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) Test(org.junit.Test)

Aggregations

HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)361 Test (org.junit.Test)329 Username (com.thoughtworks.go.server.domain.Username)131 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)36 Pipeline (com.thoughtworks.go.domain.Pipeline)27 ArrayList (java.util.ArrayList)27 Before (org.junit.Before)22 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)20 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)20 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)19 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)17 ConfigUpdateResponse (com.thoughtworks.go.config.update.ConfigUpdateResponse)17 AgentInstance (com.thoughtworks.go.domain.AgentInstance)17 UserSearchModel (com.thoughtworks.go.presentation.UserSearchModel)16 Matchers.containsString (org.hamcrest.Matchers.containsString)16 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)15 GoCipher (com.thoughtworks.go.security.GoCipher)14 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)14 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)13 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)12