本文整理汇总了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));
}
示例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);
}
示例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));
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
}