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


Java DefaultGoApiRequest类代码示例

本文整理汇总了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));
}
 
开发者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: 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());
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:11,代码来源:PluginRequest.java

示例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;
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:15,代码来源:PluginRequest.java

示例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()));
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:11,代码来源:PluginRequest.java

示例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);
    }
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:16,代码来源:PluginRequest.java

示例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);
    }
}
 
开发者ID:gocd,项目名称:kubernetes-elastic-agents,代码行数:15,代码来源:PluginRequest.java

示例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());
}
 
开发者ID:pikselpalette,项目名称:gocd-elastic-agent-marathon,代码行数:11,代码来源:PluginRequest.java

示例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);
    }
}
 
开发者ID:pikselpalette,项目名称:gocd-elastic-agent-marathon,代码行数:15,代码来源:PluginRequest.java

示例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);
    }
}
 
开发者ID:pikselpalette,项目名称:gocd-elastic-agent-marathon,代码行数:14,代码来源:PluginRequest.java

示例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);
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:12,代码来源:AbstractArtifactoryPlugin.java

示例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;
}
 
开发者ID:gocd-contrib,项目名称:docker-swarm-elastic-agents,代码行数:15,代码来源:PluginRequest.java

示例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);
    }
}
 
开发者ID:gocd-contrib,项目名称:openstack-elastic-agent,代码行数:14,代码来源:PluginRequest.java

示例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();
}
 
开发者ID:gocd-contrib,项目名称:gitter-notifier,代码行数:15,代码来源:PluginRequest.java


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