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


Java DefaultGoApiRequest.setRequestBody方法代码示例

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


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

示例1: shouldGetPluginSettingsForPluginThatExistsInDB

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
@Test
public void shouldGetPluginSettingsForPluginThatExistsInDB() {
    String PLUGIN_ID = "plugin-foo-id";

    when(pluginDescriptor.id()).thenReturn(PLUGIN_ID);
    when(pluginSqlMapDao.findPlugin(PLUGIN_ID)).thenReturn(new Plugin(PLUGIN_ID, "{\"k1\": \"v1\",\"k2\": \"v2\"}"));

    String responseBody = "expected-response";
    Map<String, String> settingsMap = new HashMap<>();
    settingsMap.put("k1", "v1");
    settingsMap.put("k2", "v2");

    when(pluginExtension.canHandlePlugin(PLUGIN_ID)).thenReturn(true);
    when(pluginExtension.pluginSettingsJSON(PLUGIN_ID, settingsMap)).thenReturn(responseBody);

    DefaultGoApiRequest apiRequest = new DefaultGoApiRequest(PluginSettingsRequestProcessor.GET_PLUGIN_SETTINGS, "1.0", null);
    apiRequest.setRequestBody("expected-request");
    GoApiResponse response = processor.process(pluginDescriptor, apiRequest);

    assertThat(response.responseCode(), is(200));
    assertThat(response.responseBody(), is(responseBody));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:23,代码来源:PluginSettingsRequestProcessorTest.java

示例2: shouldNotGetPluginSettingsForPluginThatDoesNotExistInDB

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
@Test
public void shouldNotGetPluginSettingsForPluginThatDoesNotExistInDB() {
    String PLUGIN_ID = "plugin-foo-id";
    String requestBody = "expected-request";

    when(pluginDescriptor.id()).thenReturn(PLUGIN_ID);
    when(pluginSqlMapDao.findPlugin(PLUGIN_ID)).thenReturn(new NullPlugin());
    when(pluginExtension.canHandlePlugin(PLUGIN_ID)).thenReturn(true);
    when(jsonMessageHandler.responseMessagePluginSettingsGet(any(PluginSettings.class))).thenReturn(null);

    DefaultGoApiRequest apiRequest = new DefaultGoApiRequest(PluginSettingsRequestProcessor.GET_PLUGIN_SETTINGS, "1.0", null);
    apiRequest.setRequestBody(requestBody);
    GoApiResponse response = processor.process(pluginDescriptor, apiRequest);

    assertThat(response.responseCode(), is(200));
    assertThat(response.responseBody(), is(nullValue()));
    verify(pluginExtension).pluginSettingsJSON(PLUGIN_ID, Collections.EMPTY_MAP);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:19,代码来源:PluginSettingsRequestProcessorTest.java

示例3: shouldRespondWith400IfPluginExtensionErrorsOut

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
@Test
public void shouldRespondWith400IfPluginExtensionErrorsOut() {
    String PLUGIN_ID = "plugin-foo-id";

    when(pluginDescriptor.id()).thenReturn(PLUGIN_ID);
    when(pluginSqlMapDao.findPlugin(PLUGIN_ID)).thenReturn(new Plugin(PLUGIN_ID, "{\"k1\": \"v1\",\"k2\": \"v2\"}"));

    when(pluginExtension.canHandlePlugin(PLUGIN_ID)).thenReturn(true);
    when(pluginExtension.pluginSettingsJSON(eq(PLUGIN_ID), any(Map.class))).thenThrow(RuntimeException.class);

    DefaultGoApiRequest apiRequest = new DefaultGoApiRequest(PluginSettingsRequestProcessor.GET_PLUGIN_SETTINGS, "1.0", null);
    apiRequest.setRequestBody("expected-request");

    GoApiResponse response = processor.process(pluginDescriptor, apiRequest);

    assertThat(response.responseCode(), is(400));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:18,代码来源:PluginSettingsRequestProcessorTest.java

示例4: disableAgents

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
public void disableAgents(Collection<Agent> toBeDisabled) throws ServerRequestFailedException {
    LOG.debug("[Server Ping] Disabling Agents:"+toBeDisabled.toString());
    if (toBeDisabled.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_DISABLE_AGENT, API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDisabled));

    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.disableAgents(response);
    }
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:16,代码来源:PluginRequest.java

示例5: deleteAgents

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
public void deleteAgents(Collection<Agent> toBeDeleted) throws ServerRequestFailedException {
    LOG.debug("[Server Ping] Deleting Agents:"+toBeDeleted.toString());
    if (toBeDeleted.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_DELETE_AGENT, API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDeleted));
    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.deleteAgents(response);
    }
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:15,代码来源:PluginRequest.java

示例6: disableAgents

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
public void disableAgents(Collection<Agent> toBeDisabled) throws ServerRequestFailedException {
    if (toBeDisabled.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_DISABLE_AGENT, API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDisabled));

    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.disableAgents(response);
    }
}
 
开发者ID:pikselpalette,项目名称:gocd-elastic-agent-marathon,代码行数:15,代码来源:PluginRequest.java

示例7: deleteAgents

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
public void deleteAgents(Collection<Agent> toBeDeleted) throws ServerRequestFailedException {
    if (toBeDeleted.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_DELETE_AGENT, API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDeleted));
    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.deleteAgents(response);
    }
}
 
开发者ID:pikselpalette,项目名称:gocd-elastic-agent-marathon,代码行数:14,代码来源:PluginRequest.java

示例8: deleteAgents

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
public void deleteAgents(Collection<Agent> toBeDeleted) throws ServerRequestFailedException {
    if (toBeDeleted.isEmpty()) {
        return;
    }

    DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.PROCESS_DELETE_AGENTS, API_VERSION, PLUGIN_IDENTIFIER);
    request.setRequestBody(Agent.toJSONArray(toBeDeleted));
    GoApiResponse response = accessor.submit(request);

    if (response.responseCode() != 200) {
        throw ServerRequestFailedException.deleteAgents(response);
    }
}
 
开发者ID:gocd-contrib,项目名称:openstack-elastic-agent,代码行数:14,代码来源:PluginRequest.java

示例9: shouldProcessDisableAgentRequest

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
@Test
public void shouldProcessDisableAgentRequest() throws Exception {
    AgentMetadata agent = new AgentMetadata("foo", null, null, null);
    DefaultGoApiRequest goPluginApiRequest = new DefaultGoApiRequest(PROCESS_DISABLE_AGENTS, "1.0", pluginIdentifier);
    goPluginApiRequest.setRequestBody(extension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).listAgentsResponseBody(Arrays.asList(agent)));


    AgentInstance agentInstance = AgentInstance.createFromConfig(new AgentConfig("uuid"), null);
    when(agentService.findElasticAgent("foo", "docker")).thenReturn(agentInstance);
    processor.process(pluginDescriptor, goPluginApiRequest);
    verify(agentConfigService).disableAgents(processor.usernameFor(pluginDescriptor), agentInstance);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:13,代码来源:ElasticAgentRequestProcessorTest.java

示例10: shouldProcessDeleteAgentRequest

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
@Test
public void shouldProcessDeleteAgentRequest() throws Exception {
    AgentMetadata agent = new AgentMetadata("foo", null, null, null);
    DefaultGoApiRequest goPluginApiRequest = new DefaultGoApiRequest(PROCESS_DELETE_AGENTS, "1.0", pluginIdentifier);
    goPluginApiRequest.setRequestBody(extension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).listAgentsResponseBody(Arrays.asList(agent)));


    AgentInstance agentInstance = AgentInstance.createFromConfig(new AgentConfig("uuid"), null);
    when(agentService.findElasticAgent("foo", "docker")).thenReturn(agentInstance);
    processor.process(pluginDescriptor, goPluginApiRequest);
    verify(agentConfigService).deleteAgents(processor.usernameFor(pluginDescriptor), agentInstance);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:13,代码来源:ElasticAgentRequestProcessorTest.java

示例11: requestWithCredentials

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
public static GoApiRequest requestWithCredentials(String username, String password) {
    final DefaultGoApiRequest defaultGoApiRequest = new DefaultGoApiRequest(null, null, null);
    defaultGoApiRequest.setRequestBody(requestJson(username, password));
    return defaultGoApiRequest;
}
 
开发者ID:gocd,项目名称:gocd-filebased-authentication-plugin,代码行数:6,代码来源:RequestMother.java

示例12: disableAgents

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入方法依赖的package包/类
public void disableAgents(Collection<Agent> toBeDisabled) throws ServerRequestFailedException {

        if (toBeDisabled.isEmpty()) {
            return;
        }

        DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.PROCESS_DISABLE_AGENTS, API_VERSION, PLUGIN_IDENTIFIER);

        request.setRequestBody(Agent.toJSONArray(toBeDisabled));

        GoApiResponse response = accessor.submit(request);

        if (response.responseCode() != 200) {
            throw ServerRequestFailedException.disableAgents(response);
        }
    }
 
开发者ID:gocd-contrib,项目名称:openstack-elastic-agent,代码行数:17,代码来源:PluginRequest.java


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