• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DefaultGoApiRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



DefaultGoApiRequest类属于com.thoughtworks.go.plugin.api.request包,在下文中一共展示了DefaultGoApiRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: shouldReturnAServerIdInJSONForm

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
@Test
public void shouldReturnAServerIdInJSONForm() throws Exception {
    String pluginId = "plugin_id";
    DefaultGoApiRequest request = new DefaultGoApiRequest(ServerInfoRequestProcessor.GET_SERVER_ID, "1.0", new GoPluginIdentifier("foo", Arrays.asList("1.0")));

    when(pluginDescriptor.id()).thenReturn(pluginId);
    when(pluginExtension.canHandlePlugin(pluginId)).thenReturn(true);
    when(pluginExtension.serverInfoJSON(pluginId, serverConfig.getServerId(), serverConfig.getSiteUrl().getUrl(), serverConfig.getSecureSiteUrl().getUrl())).thenReturn("server_info");

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

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


示例17: shouldReturnAErrorResponseIfExtensionDoesNotSupportServerInfo

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
@Test
public void shouldReturnAErrorResponseIfExtensionDoesNotSupportServerInfo() throws Exception {
    String pluginId = "plugin_id";
    DefaultGoApiRequest request = new DefaultGoApiRequest(ServerInfoRequestProcessor.GET_SERVER_ID, "bad-version", new GoPluginIdentifier("foo", Arrays.asList("1.0")));

    when(pluginDescriptor.id()).thenReturn(pluginId);
    when(pluginExtension.canHandlePlugin(pluginId)).thenReturn(true);
    when(pluginExtension.serverInfoJSON(any(String.class), any(String.class), any(String.class), any(String.class))).thenThrow(new UnsupportedOperationException("Operation not supported."));

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

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


示例18: shouldRespondWith400IfNoneOfExtensionsCanHandleThePlugin

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

    when(pluginDescriptor.id()).thenReturn(PLUGIN_ID);
    when(pluginExtension.canHandlePlugin(PLUGIN_ID)).thenReturn(false);

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

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


示例19: shouldProcessInvalidateCacheRequest

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
@Test
public void shouldProcessInvalidateCacheRequest() throws Exception {
    PluginRoleService pluginRoleService = mock(PluginRoleService.class);
    when(authorizationExtension.getMessageConverter(AuthorizationMessageConverterV1.VERSION)).thenReturn(new AuthorizationMessageConverterV1());

    GoApiRequest request = new DefaultGoApiRequest(INVALIDATE_CACHE_REQUEST.requestName(), "1.0", null);
    AuthorizationRequestProcessor authorizationRequestProcessor = new AuthorizationRequestProcessor(registry, null, authorizationExtension, pluginRoleService);

    GoApiResponse response = authorizationRequestProcessor.process(pluginDescriptor, request);

    assertThat(response.responseCode(), is(200));
    verify(pluginRoleService).invalidateRolesFor("cd.go.authorization.github");
}
 
开发者ID:gocd,项目名称:gocd,代码行数:14,代码来源:AuthorizationRequestProcessorTest.java


示例20: shouldProcessListAgentRequest

import com.thoughtworks.go.plugin.api.request.DefaultGoApiRequest; //导入依赖的package包/类
@Test
public void shouldProcessListAgentRequest() throws Exception {
    LinkedMultiValueMap<String, ElasticAgentMetadata> allAgents = new LinkedMultiValueMap<>();
    ElasticAgentMetadata agent = new ElasticAgentMetadata("foo", "bar", "docker", AgentRuntimeStatus.Building, AgentConfigStatus.Disabled);
    allAgents.put("docker", Arrays.asList(agent));

    when(agentService.allElasticAgents()).thenReturn(allAgents);
    GoApiResponse response = processor.process(pluginDescriptor, new DefaultGoApiRequest(REQUEST_SERVER_LIST_AGENTS, "1.0", pluginIdentifier));

    JSONAssert.assertEquals("[{\"agent_id\":\"bar\",\"agent_state\":\"Building\",\"build_state\":\"Building\",\"config_state\":\"Disabled\"}]", response.responseBody(), true);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:12,代码来源:ElasticAgentRequestProcessorTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SecurityHelper类代码示例发布时间:2022-05-22
下一篇:
Java MappingBuilder类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap