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