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


Java DefaultGoPluginApiRequest.setRequestBody方法代码示例

本文整理汇总了Java中com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest.setRequestBody方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultGoPluginApiRequest.setRequestBody方法的具体用法?Java DefaultGoPluginApiRequest.setRequestBody怎么用?Java DefaultGoPluginApiRequest.setRequestBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest的用法示例。


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

示例1: submitRequest

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的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

示例2: handleShouldReturnErrorResponseGivenEmptyRequestBody

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnErrorResponseGivenEmptyRequestBody() {
    DefaultGoPluginApiRequest request = validRequest;
    request.setRequestBody(null);
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.INTERNAL_ERROR));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:8,代码来源:CheckoutRequestHandlerTest.java

示例3: execute_shouldVerifyIfThePasswordFileExists

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void execute_shouldVerifyIfThePasswordFileExists() throws Exception {
    DefaultGoPluginApiRequest request = new DefaultGoPluginApiRequest(null, null, null);
    request.setRequestBody("{\"PasswordFilePath\": \"some_path\"}");

    GoPluginApiResponse response = new VerifyConnectionRequestExecutor(request).execute();

    String expectedResponse = "{\"message\":\"No password file at path `some_path`.\",\"status\":\"failure\"}";
    assertThat(response.responseBody(), is(expectedResponse));
}
 
开发者ID:gocd,项目名称:gocd-filebased-authentication-plugin,代码行数:11,代码来源:VerifyConnectionRequestExecutorTest.java

示例4: execute_shouldVerifyIfPasswordFilePathPointsToANormalFile

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void execute_shouldVerifyIfPasswordFilePathPointsToANormalFile() throws Exception {
    File folder = this.folder.newFolder("subfolder");

    DefaultGoPluginApiRequest request = new DefaultGoPluginApiRequest(null, null, null);
    request.setRequestBody(String.format("{\"PasswordFilePath\": \"%s\"}", folder.getAbsolutePath()));

    GoPluginApiResponse response = new VerifyConnectionRequestExecutor(request).execute();

    String expectedResponse = String.format("{\"message\":\"Password file path `%s` is not a normal file.\",\"status\":\"failure\"}", folder.getAbsolutePath());
    assertThat(response.responseBody(), is(expectedResponse));
}
 
开发者ID:gocd,项目名称:gocd-filebased-authentication-plugin,代码行数:13,代码来源:VerifyConnectionRequestExecutorTest.java

示例5: execute_shouldReturnASuccessResponseIfValidationAndVerificationPasses

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void execute_shouldReturnASuccessResponseIfValidationAndVerificationPasses() throws Exception {
    File passwordFile = this.folder.newFile("password.properties");

    DefaultGoPluginApiRequest request = new DefaultGoPluginApiRequest(null, null, null);
    request.setRequestBody(String.format("{\"PasswordFilePath\": \"%s\"}", passwordFile.getAbsolutePath()));

    GoPluginApiResponse response = new VerifyConnectionRequestExecutor(request).execute();

    assertThat(response.responseBody(), is("{\"message\":\"Connection ok\",\"status\":\"success\"}"));
}
 
开发者ID:gocd,项目名称:gocd-filebased-authentication-plugin,代码行数:12,代码来源:VerifyConnectionRequestExecutorTest.java

示例6: handleShouldReturnErrorResponseGivenInvalidJson

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnErrorResponseGivenInvalidJson() {
    DefaultGoPluginApiRequest request = validRequest;
    request.setRequestBody("Invalid JSON");
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.INTERNAL_ERROR));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:8,代码来源:LatestRevisionsSinceRequestHandlerTest.java

示例7: handleShouldReturnIncompleteRequestResponseOnMissingScmConfigurationField

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnIncompleteRequestResponseOnMissingScmConfigurationField() {
    String missingScmConfigurationJson = "{\"destination-folder\":\"/var/lib/go-agent/pipelines/pipeline-name/destination\",\"revision\": {\"revision\": \"revision-1\",\"timestamp\": \"2011-07-14T19:43:37.100Z\",\"data\":{}}}";
    DefaultGoPluginApiRequest request = validRequest;
    request.setRequestBody(missingScmConfigurationJson);
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.VALIDATION_FAILED));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:9,代码来源:CheckoutRequestHandlerTest.java

示例8: handleShouldReturnIncompleteRequestResponseOnMissingScmConfigurationField

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnIncompleteRequestResponseOnMissingScmConfigurationField() {
    String missingScmConfigurationJson = "{\"scm-data\":{},\"flyweight-folder\":\"/server/pipelines/flyweight/961e6dd6-255a-40ed-8792-1a1477b942d5\",\"previous-revision\": {\"revision\": \"revision-1\",\"timestamp\": \"2011-07-14T19:43:37.100Z\",\"data\":{}}}";
    DefaultGoPluginApiRequest request = validRequest;
    request.setRequestBody(missingScmConfigurationJson);
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.VALIDATION_FAILED));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:9,代码来源:LatestRevisionsSinceRequestHandlerTest.java

示例9: handleShouldReturnIncompleteRequestResponseOnMissingFlyweightFolderField

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnIncompleteRequestResponseOnMissingFlyweightFolderField() {
    String missingFlyweightFolderJson = "{\"scm-configuration\":{\"url\":{\"value\":\"https://github.com/kszatan/gocd-phabricator-staging-material.git\"}},\"scm-data\":{},\"previous-revision\": {\"revision\": \"revision-1\",\"timestamp\": \"2011-07-14T19:43:37.100Z\",\"data\":{}}}";
    DefaultGoPluginApiRequest request = validRequest;
    request.setRequestBody(missingFlyweightFolderJson);
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.VALIDATION_FAILED));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:9,代码来源:LatestRevisionsSinceRequestHandlerTest.java

示例10: handleShouldReturnIncompleteRequestResponseOnMissingRevisionField

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnIncompleteRequestResponseOnMissingRevisionField() {
    String missingRevisionJson = "{\"scm-configuration\":{\"url\":{\"value\":\"https://github.com/kszatan/gocd-phabricator-staging-material.git\"}},\"destination-folder\":\"/var/lib/go-agent/pipelines/pipeline-name/destination\"}";
    DefaultGoPluginApiRequest request = validRequest;
    request.setRequestBody(missingRevisionJson);
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.VALIDATION_FAILED));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:9,代码来源:CheckoutRequestHandlerTest.java

示例11: handleShouldReturnIncompleteRequestResponseOnMissingScmConfigurationField

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnIncompleteRequestResponseOnMissingScmConfigurationField() {
    String missingScmConfigurationJson = "{\"flyweight-folder\":\"/tmp/repo\"}";
    DefaultGoPluginApiRequest request = validRequest;
    request.setRequestBody(missingScmConfigurationJson);
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.VALIDATION_FAILED));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:9,代码来源:LatestRevisionRequestHandlerTest.java

示例12: handleShouldReturnIncompleteRequestResponseOnMissingFlyweightFolderField

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnIncompleteRequestResponseOnMissingFlyweightFolderField() {
    String missingFlyweightFolderJson = "{\"scm-configuration\":{\"url\":{\"value\":\"[email protected]:wiki.git\"}},\"scm-data\":{}}";
    DefaultGoPluginApiRequest request = validRequest;
    request.setRequestBody(missingFlyweightFolderJson);
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.VALIDATION_FAILED));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:9,代码来源:LatestRevisionRequestHandlerTest.java

示例13: handleShouldReturnErrorResponseWhenGivenInvalidJson

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnErrorResponseWhenGivenInvalidJson() {
    DefaultGoPluginApiRequest request = new DefaultGoPluginApiRequest("scm", "1.0", "validate-scm-configuration");
    request.setRequestBody("Invalid JSON");
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.INTERNAL_ERROR));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:8,代码来源:ValidateScmConfigurationRequestHandlerTest.java

示例14: handleShouldReturnValidationFailedResponseWhenGivenIncompleteJson

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnValidationFailedResponseWhenGivenIncompleteJson() {
    DefaultGoPluginApiRequest request = new DefaultGoPluginApiRequest("scm", "1.0", "validate-scm-configuration");
    request.setRequestBody("{}");
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.VALIDATION_FAILED));
    assertThat(response.responseBody(), equalTo("Missing fields: [scm-configuration]"));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:9,代码来源:CheckScmConnectionRequestHandlerTest.java

示例15: handleShouldReturnInternalErrorResponseWhenGivenInvalidJson

import com.thoughtworks.go.plugin.api.request.DefaultGoPluginApiRequest; //导入方法依赖的package包/类
@Test
public void handleShouldReturnInternalErrorResponseWhenGivenInvalidJson() {
    DefaultGoPluginApiRequest request = new DefaultGoPluginApiRequest("scm", "1.0", "validate-scm-configuration");
    request.setRequestBody("Invalid JSON");
    GoPluginApiResponse response = handler.handle(request);
    assertThat(response.responseCode(), equalTo(DefaultGoPluginApiResponse.INTERNAL_ERROR));
    ScmConnectionResponse scmConnectionResponse = GsonService.fromJson(response.responseBody(), ScmConnectionResponse.class);
    assertThat(scmConnectionResponse.status, equalTo("failure"));
    assertThat(scmConnectionResponse.messages.size(), equalTo(1));
    assertThat(scmConnectionResponse.messages.iterator().next(), equalTo("Malformed JSON: Invalid JSON"));
}
 
开发者ID:kszatan,项目名称:gocd-phabricator-staging-material,代码行数:12,代码来源:CheckScmConnectionRequestHandlerTest.java


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