use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class MaterialConfigServiceTest method shouldPopulateErrorCorrectlyWhenUnauthorizedToViewMaterial_getMaterialConfigByFingerprint.
@Test
public void shouldPopulateErrorCorrectlyWhenUnauthorizedToViewMaterial_getMaterialConfigByFingerprint() {
HttpOperationResult result = new HttpOperationResult();
GitMaterialConfig gitMaterialConfig = new GitMaterialConfig("http://another.com");
MaterialConfig materialConfig = materialConfigService.getMaterialConfig(user, gitMaterialConfig.getFingerprint(), result);
assertThat(materialConfig, is(nullValue()));
assertThat(result.httpCode(), is(401));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class MaterialConfigServiceTest method shouldGetMaterialConfigByFingerprint.
@Test
public void shouldGetMaterialConfigByFingerprint() {
HttpOperationResult result = new HttpOperationResult();
GitMaterialConfig gitMaterialConfig = new GitMaterialConfig("http://crap.com");
MaterialConfig materialConfig = materialConfigService.getMaterialConfig(user, gitMaterialConfig.getFingerprint(), result);
assertThat(materialConfig, is(gitMaterialConfig));
assertThat(result.canContinue(), is(true));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineOperationsControllerV1Delegate method schedule.
public String schedule(Request req, Response res) throws IOException {
HttpOperationResult result = new HttpOperationResult();
String pipelineName = req.params("pipeline_name");
pipelineTriggerService.schedule(pipelineName, getScheduleOptions(req), currentUsername(), result);
return renderHTTPOperationResult(result, req, res);
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method testShouldThrowErrorOnUpdatingAgentOnInvalidInputs.
@Test
public void testShouldThrowErrorOnUpdatingAgentOnInvalidInputs() throws Exception {
AgentConfig agent = createDisabledAndIdleAgent(UUID);
String originalHostname = agent.getHostname();
List<String> originalResourceNames = agent.getResourceConfigs().resourceNames();
goConfigDao.load();
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getHostname(), is(not("some-hostname")));
HttpOperationResult operationResult = new HttpOperationResult();
AgentInstance agentInstance = agentService.updateAgentAttributes(USERNAME, operationResult, UUID, "some-hostname", "lin!ux", null, TriState.UNSET);
assertThat(operationResult.httpCode(), is(422));
assertThat(operationResult.message(), is("Updating agent failed:"));
assertThat(agentInstance.agentConfig().getResourceConfigs().first().errors().on(JobConfig.RESOURCES), is("Resource name 'lin!ux' is not valid. Valid names much match '^[-\\w\\s|.]*$'"));
assertThat(agentService.agents().size(), is(1));
assertThat(getFirstAgent().getHostname(), is(originalHostname));
assertThat(getFirstAgent().getResourceConfigs().resourceNames(), is(originalResourceNames));
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentServiceIntegrationTest method shouldDisableMultipleAgents.
@Test
public void shouldDisableMultipleAgents() {
AgentConfig agentConfig1 = createEnabledAgent(UUID);
AgentConfig agentConfig2 = createEnabledAgent(UUID2);
HttpOperationResult operationResult = new HttpOperationResult();
agentService.disableAgents(USERNAME, operationResult, Arrays.asList(UUID, UUID2));
assertThat(operationResult.httpCode(), is(200));
assertThat(isDisabled(agentConfig1), is(true));
assertThat(isDisabled(agentConfig2), is(true));
assertThat(operationResult.message(), containsString("Disabled 2 agent(s)"));
}
Aggregations