当前位置: 首页>>代码示例>>Java>>正文


Java DefaultGoApiResponse类代码示例

本文整理汇总了Java中com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse的典型用法代码示例。如果您正苦于以下问题:Java DefaultGoApiResponse类的具体用法?Java DefaultGoApiResponse怎么用?Java DefaultGoApiResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultGoApiResponse类属于com.thoughtworks.go.plugin.api.response包,在下文中一共展示了DefaultGoApiResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldContainValidFieldsInResponseMessage

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Test
public void shouldContainValidFieldsInResponseMessage() throws UnhandledRequestTypeException {
    GoApiResponse settingsResponse = DefaultGoApiResponse.success("{}");
    when(goAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);

    GoPluginApiResponse response = parseAndGetResponseForDir(tempDir.getRoot());

    assertThat(response.responseCode(), is(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE));
    final JsonParser parser = new JsonParser();
    JsonElement responseObj = parser.parse(response.responseBody());
    assertTrue(responseObj.isJsonObject());
    JsonObject obj = responseObj.getAsJsonObject();
    assertTrue(obj.has("errors"));
    assertTrue(obj.has("pipelines"));
    assertTrue(obj.has("environments"));
    assertTrue(obj.has("target_version"));
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:18,代码来源:YamlConfigPluginIntegrationTest.java

示例2: settingsParsing

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Test
public void settingsParsing() throws Exception {
	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	plugin.initializeGoApplicationAccessor(new GoApplicationAccessor(){
		
		@Override
		public GoApiResponse submit(GoApiRequest request)
		{
			String json = "{"
					+ "\"connectTimeout\": \"1\","
					+ "\"socketTimeout\": \"2\","
					+ "\"connectionRequestTimeout\": \"3\","
					+ "\"proxyUrl\": \"http://proxy.example.com:1234\","
					+ "\"connPoolSize\": \"3\""
					+ "}";
			DefaultGoApiResponse response = new DefaultGoApiResponse(200);
			response.setResponseBody(json);
			return response;
		}
	});

	// just make sure there is no exception
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:24,代码来源:IntegrationTests.java

示例3: execute

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public GoPluginApiResponse execute(GoPluginApiRequest request) {

    int responseCode = DefaultGoApiResponse.SUCCESS_RESPONSE_CODE;
    final Map<String, Object> response = new HashMap<>();
    try {
        response.put("displayValue", taskView.displayValue());
        response.put("template", taskView.template());
    } catch(PluginException ex) {

        responseCode = DefaultGoApiResponse.INTERNAL_ERROR;
        response.put("exception", ex.getMessage());
    }
    return createResponse(responseCode, response);
}
 
开发者ID:jmnarloch,项目名称:gocd-task-plugin-api,代码行数:19,代码来源:ViewCommand.java

示例4: handleTaskView

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Override
protected GoPluginApiResponse handleTaskView(GoPluginApiRequest request) {
    int responseCode = DefaultGoApiResponse.SUCCESS_RESPONSE_CODE;
    HashMap view = new HashMap();
    view.put("displayValue", "Monitoring - Check MK");
    try {
        String checkMkTemplate = IOUtils.toString(getClass().getResourceAsStream("/views/checkMk.template.html"), "UTF-8");
        view.put("template", checkMkTemplate);
    } catch (Exception e) {
        responseCode = DefaultGoApiResponse.INTERNAL_ERROR;
        String errorMessage = "Failed to find template: " + e.getMessage();
        view.put("exception", errorMessage);
        logger.error(errorMessage, e);
    }
    return createResponse(responseCode, view);
}
 
开发者ID:Haufe-Lexware,项目名称:gocd-plugins,代码行数:17,代码来源:CheckMkTask.java

示例5: submitRequest

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
public <T> T submitRequest(String pluginId, String requestName, PluginInteractionCallback<T> pluginInteractionCallback) {
    if (!pluginManager.isPluginOfType(extensionName, pluginId)) {
        throw new PluginNotFoundException(format("Did not find '%s' plugin with id '%s'. Looks like plugin is missing", extensionName, pluginId));
    }
    try {
        String resolvedExtensionVersion = pluginManager.resolveExtensionVersion(pluginId, goSupportedVersions);
        DefaultGoPluginApiRequest apiRequest = new DefaultGoPluginApiRequest(extensionName, resolvedExtensionVersion, requestName);
        apiRequest.setRequestBody(pluginInteractionCallback.requestBody(resolvedExtensionVersion));
        apiRequest.setRequestParams(pluginInteractionCallback.requestParams(resolvedExtensionVersion));
        apiRequest.setRequestHeaders(pluginInteractionCallback.requestHeaders(resolvedExtensionVersion));
        GoPluginApiResponse response = pluginManager.submitTo(pluginId, apiRequest);
        if (response == null) {
            throw new RuntimeException("The plugin sent a null response");
        }
        if (DefaultGoApiResponse.SUCCESS_RESPONSE_CODE == response.responseCode()) {
            return pluginInteractionCallback.onSuccess(response.responseBody(), resolvedExtensionVersion);
        }
        throw new RuntimeException(format("The plugin sent a response that could not be understood by Go. Plugin returned with code '%s' and the following response: '%s'", response.responseCode(), response.responseBody()));
    } catch (Exception e) {
        throw new RuntimeException(format("Interaction with plugin with id '%s' implementing '%s' extension failed while requesting for '%s'. Reason: [%s]", pluginId, extensionName, requestName, e.getMessage()), e);
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:23,代码来源:PluginRequestHelper.java

示例6: shouldValidateTask

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Test
public void shouldValidateTask() {
    GoPluginApiResponse response = mock(GoPluginApiResponse.class);
    TaskExtension jsonBasedTaskExtension = new TaskExtension(pluginManager);
    TaskConfig taskConfig = mock(TaskConfig.class);

    when(response.responseCode()).thenReturn(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE);
    when(pluginManager.isPluginOfType(PLUGGABLE_TASK_EXTENSION, pluginId)).thenReturn(true);
    when(response.responseBody()).thenReturn("{\"errors\":{\"key\":\"error\"}}");
    when(pluginManager.submitTo(eq(pluginId), any(GoPluginApiRequest.class))).thenReturn(response);
    ValidationResult validationResult = jsonBasedTaskExtension.validate(pluginId, taskConfig);

    verify(pluginManager).submitTo(eq(pluginId), any(GoPluginApiRequest.class));
    assertFalse(validationResult.isSuccessful());
    assertEquals(validationResult.getErrors().get(0).getKey(), "key");
    assertEquals(validationResult.getErrors().get(0).getMessage(), "error");
}
 
开发者ID:gocd,项目名称:gocd,代码行数:18,代码来源:TaskExtensionTest.java

示例7: shouldConstructTheRequest

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Test
public void shouldConstructTheRequest() {
    final String requestBody = "request_body";
    when(response.responseCode()).thenReturn(DefaultGoApiResponse.SUCCESS_RESPONSE_CODE);

    final GoPluginApiRequest[] generatedRequest = {null};
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            generatedRequest[0] = (GoPluginApiRequest) invocationOnMock.getArguments()[1];
            return response;
        }
    }).when(pluginManager).submitTo(eq(pluginId), any(GoPluginApiRequest.class));


    helper.submitRequest(pluginId, requestName, new DefaultPluginInteractionCallback<Object>() {
        @Override
        public String requestBody(String resolvedExtensionVersion) {
            return requestBody;
        }
    });
    assertThat(generatedRequest[0].requestBody(), is(requestBody));
    assertThat(generatedRequest[0].extension(), is(extensionName));
    assertThat(generatedRequest[0].requestName(), is(requestName));
    assertTrue(generatedRequest[0].requestParameters().isEmpty());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:27,代码来源:PluginRequestHelperTest.java

示例8: shouldReturnServerIdInCorrectJSONFormat

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Test
public void shouldReturnServerIdInCorrectJSONFormat() throws Exception {

    ServerConfig serverConfig = new ServerConfig();
    serverConfig.ensureServerIdExists();
    serverConfig.setSecureSiteUrl("https://example.com:8154/go");
    serverConfig.setSiteUrl("http://example.com:8153/go");


    DefaultGoApiResponse response = new ServerInfoMessageConverterV1().getServerInfo(serverConfig);

    JsonAssert.assertJsonEquals("{\n" +
            "  \"server_id\": \"" + serverConfig.getServerId() + "\",\n" +
            "  \"site_url\": \"" + serverConfig.getSiteUrl().getUrl() + "\",\n" +
            "  \"secure_site_url\": \"" + serverConfig.getSecureSiteUrl().getUrl() + "\"\n" +
            "}", response.responseBody());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:18,代码来源:ServerInfoMessageConverterV1Test.java

示例9: process

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Override
public GoApiResponse process(GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    try {
        String version = goPluginApiRequest.apiVersion();
        if (!goSupportedVersions.contains(version)) {
            throw new RuntimeException(String.format("Unsupported '%s' API version: %s. Supported versions: %s", goPluginApiRequest.api(), version, goSupportedVersions));
        }

        if (goPluginApiRequest.api().equals(PUT_INTO_SESSION)) {
            return handleSessionPutRequest(goPluginApiRequest);
        }
        if (goPluginApiRequest.api().equals(GET_FROM_SESSION)) {
            return handleSessionGetRequest(goPluginApiRequest);
        }
        if (goPluginApiRequest.api().equals(REMOVE_FROM_SESSION)) {
            return handleSessionRemoveRequest(goPluginApiRequest);
        }
    } catch (Exception e) {
        LOGGER.error("Error occurred while authenticating user", e);
    }
    return new DefaultGoApiResponse(500);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:23,代码来源:SessionRequestProcessor.java

示例10: process

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Override
public GoApiResponse process(GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    try {
        GoPluginExtension extension = extensionFor(pluginDescriptor.id());

        PluginSettings pluginSettings = pluginSettingsFor(pluginDescriptor.id());

        DefaultGoApiResponse response = new DefaultGoApiResponse(200);
        response.setResponseBody(extension.pluginSettingsJSON(pluginDescriptor.id(), pluginSettings.getSettingsAsKeyValuePair()));

        return response;
    } catch (Exception e) {
        LOGGER.error(format("Error processing PluginSettings request from plugin: %s.", pluginDescriptor.id()), e);

        DefaultGoApiResponse errorResponse = new DefaultGoApiResponse(400);
        errorResponse.setResponseBody(format("Error while processing get PluginSettings request - %s", e.getMessage()));

        return errorResponse;
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:21,代码来源:PluginSettingsRequestProcessor.java

示例11: process

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Override
public GoApiResponse process(final GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    switch (goPluginApiRequest.api()) {
        case PROCESS_DISABLE_AGENTS:
            Collection<AgentMetadata> agentsToDisable = elasticAgentExtension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).deleteAndDisableAgentRequestBody(goPluginApiRequest.requestBody());
            if (agentsToDisable.isEmpty()) {
                return new DefaultGoApiResponse(200);
            }
            return processDisableAgent(pluginDescriptor, goPluginApiRequest);
        case PROCESS_DELETE_AGENTS:
            Collection<AgentMetadata> agentsToDelete = elasticAgentExtension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).deleteAndDisableAgentRequestBody(goPluginApiRequest.requestBody());
            if (agentsToDelete.isEmpty()) {
                return new DefaultGoApiResponse(200);
            }
            return processDeleteAgent(pluginDescriptor, goPluginApiRequest);
        case REQUEST_SERVER_LIST_AGENTS:
            return processListAgents(pluginDescriptor, goPluginApiRequest);
        default:
            return DefaultGoApiResponse.error("Illegal api request");
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:22,代码来源:ElasticAgentRequestProcessor.java

示例12: processListAgents

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
private GoApiResponse processListAgents(GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    LOGGER.debug("Listing agents for plugin {}", pluginDescriptor.id());
    List<ElasticAgentMetadata> elasticAgents = agentService.allElasticAgents().get(pluginDescriptor.id());

    Collection<AgentMetadata> metadata;
    if (elasticAgents == null) {
        metadata = new ArrayList<>();
    } else {
        metadata = elasticAgents.stream().map(new Function<ElasticAgentMetadata, AgentMetadata>() {
            @Override
            public AgentMetadata apply(ElasticAgentMetadata obj) {
                return toAgentMetadata(obj);
            }
        }).collect(Collectors.toList());
    }

    String responseBody = elasticAgentExtension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).listAgentsResponseBody(metadata);
    return DefaultGoApiResponse.success(responseBody);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:ElasticAgentRequestProcessor.java

示例13: setUp

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
    plugin = new YamlConfigPlugin();
    goAccessor = mock(GoApplicationAccessor.class);
    plugin.initializeGoApplicationAccessor(goAccessor);
    GoApiResponse settingsResponse = DefaultGoApiResponse.success("{}");
    when(goAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);
    parser = new JsonParser();
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:10,代码来源:YamlConfigPluginIntegrationTest.java

示例14: shouldRespondSuccessToParseDirectoryRequestWhenPluginHasConfiguration

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
@Test
public void shouldRespondSuccessToParseDirectoryRequestWhenPluginHasConfiguration() throws UnhandledRequestTypeException {
    GoApiResponse settingsResponse = DefaultGoApiResponse.success("{}");
    when(goAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);

    GoPluginApiResponse response = parseAndGetResponseForDir(tempDir.getRoot());

    verify(goAccessor, times(1)).submit(any(GoApiRequest.class));
    assertThat(response.responseCode(), is(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE));
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:11,代码来源:YamlConfigPluginIntegrationTest.java

示例15: createPluginScm

import com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse; //导入依赖的package包/类
protected ArtifactoryScmPlugin createPluginScm() {
	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	plugin.initializeGoApplicationAccessor(new GoApplicationAccessor(){
		
		@Override
		public GoApiResponse submit(GoApiRequest request)
		{
			return new DefaultGoApiResponse(200);
		}
	});
	return plugin;
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:13,代码来源:IntegrationTests.java


注:本文中的com.thoughtworks.go.plugin.api.response.DefaultGoApiResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。