本文整理汇总了Java中com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest类的典型用法代码示例。如果您正苦于以下问题:Java DefaultGoApiRequest类的具体用法?Java DefaultGoApiRequest怎么用?Java DefaultGoApiRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DefaultGoApiRequest类属于com.thoughtworks.go.plugin.api.request包,在下文中一共展示了DefaultGoApiRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getSeverInfo
import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
public ServerInfo getSeverInfo() throws ServerRequestFailedException {
DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_INFO, SERVER_INFO_API_VERSION, PLUGIN_IDENTIFIER);
GoApiResponse response = accessor.submit(request);
if (response.responseCode() != 200) {
throw ServerRequestFailedException.serverInfo(response);
}
return ServerInfo.fromJSON(response.responseBody());
}
示例5: getPluginSettings
import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
public PluginSettings getPluginSettings() throws ServerRequestFailedException {
DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_GET_PLUGIN_SETTINGS, API_VERSION, PLUGIN_IDENTIFIER);
GoApiResponse response = accessor.submit(request);
if (response.responseCode() != 200) {
throw ServerRequestFailedException.getPluginSettings(response);
}
final PluginSettings pluginSettings = PluginSettings.fromJSON(response.responseBody());
if (pluginSettings == null) {
throw new PluginSettingsNotConfiguredException();
}
return pluginSettings;
}
示例6: listAgents
import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
public Agents listAgents() throws ServerRequestFailedException {
DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_LIST_AGENTS, API_VERSION, PLUGIN_IDENTIFIER);
GoApiResponse response = accessor.submit(request);
if (response.responseCode() != 200) {
throw ServerRequestFailedException.listAgents(response);
}
return new Agents(Agent.fromJSONArray(response.responseBody()));
}
示例7: 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);
}
}
示例8: 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);
}
}
示例9: getPluginSettings
import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
public PluginSettings getPluginSettings() throws ServerRequestFailedException {
DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_GET_PLUGIN_SETTINGS, API_VERSION, PLUGIN_IDENTIFIER);
GoApiResponse response = accessor.submit(request);
if (response.responseCode() != 200) {
throw ServerRequestFailedException.getPluginSettings(response);
}
return PluginSettings.fromJSON(response.responseBody());
}
示例10: 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);
}
}
示例11: 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);
}
}
示例12: initializeGoApplicationAccessor
import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
@Override
public void initializeGoApplicationAccessor(GoApplicationAccessor goApplicationAccessor) {
logger.debug("initializeGoApplicationAccessor()");
GoApiRequest request = new DefaultGoApiRequest(REQUEST_SETTINGS_GET_THEM, GO_API_VERSION, pluginIdentifier());
GoApiResponse response = goApplicationAccessor.submit(request);
String json = response.responseBody();
httpClient = createHttpClient(json);
}
示例13: getPluginSettings
import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
public PluginSettings getPluginSettings() throws ServerRequestFailedException {
DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_GET_PLUGIN_SETTINGS, API_VERSION, PLUGIN_IDENTIFIER);
GoApiResponse response = accessor.submit(request);
if (response.responseCode() != 200) {
throw ServerRequestFailedException.getPluginSettings(response);
}
final PluginSettings pluginSettings = PluginSettings.fromJSON(response.responseBody());
if(pluginSettings == null){
throw new PluginSettingsNotConfiguredException();
}
return pluginSettings;
}
示例14: 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);
}
}
示例15: getPluginSettings
import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
public PluginSettings getPluginSettings() throws ServerRequestFailedException {
DefaultGoApiRequest request = new DefaultGoApiRequest(Constants.REQUEST_SERVER_GET_PLUGIN_SETTINGS, Constants.API_VERSION, Constants.PLUGIN_IDENTIFIER);
GoApiResponse response = accessor.submit(request);
if (response.responseCode() != 200) {
throw ServerRequestFailedException.getPluginSettings(response);
}
if (StringUtils.isNotBlank(response.responseBody())) {
return PluginSettings.fromJSON(response.responseBody());
}
return new PluginSettings();
}