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

Java GoApiRequest类代码示例

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

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



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

示例1: shouldContainValidFieldsInResponseMessage

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Test
public void shouldContainValidFieldsInResponseMessage() throws UnhandledRequestTypeException {
    GoApiResponse settingsResponse = DefaultGoApiResponse.success("{}");
    when(goAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);

    GoPluginApiResponse response = parseAndGetResponseForDir(tempDir.getRoot());

    assertThat(response.responseCode(), is(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE));
    final JsonParser parser = new JsonParser();
    JsonElement responseObj = parser.parse(response.responseBody());
    assertTrue(responseObj.isJsonObject());
    JsonObject obj = responseObj.getAsJsonObject();
    assertTrue(obj.has("errors"));
    assertTrue(obj.has("pipelines"));
    assertTrue(obj.has("environments"));
    assertTrue(obj.has("target_version"));
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:18,代码来源:YamlConfigPluginIntegrationTest.java


示例2: settingsParsing

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Test
public void settingsParsing() throws Exception {
	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	plugin.initializeGoApplicationAccessor(new GoApplicationAccessor(){
		
		@Override
		public GoApiResponse submit(GoApiRequest request)
		{
			String json = "{"
					+ "\"connectTimeout\": \"1\","
					+ "\"socketTimeout\": \"2\","
					+ "\"connectionRequestTimeout\": \"3\","
					+ "\"proxyUrl\": \"http://proxy.example.com:1234\","
					+ "\"connPoolSize\": \"3\""
					+ "}";
			DefaultGoApiResponse response = new DefaultGoApiResponse(200);
			response.setResponseBody(json);
			return response;
		}
	});

	// just make sure there is no exception
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:24,代码来源:IntegrationTests.java


示例3: testASingleEmailAddressSendsEmail

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Test
public void testASingleEmailAddressSendsEmail() throws Exception {
    settingsResponseMap.put("receiver_email_id", "[email protected]");

    GoApiResponse settingsResponse = testSettingsResponse();

    when(goApplicationAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);

    GoPluginApiRequest requestFromServer = testStageChangeRequestFromServer();

    emailNotificationPlugin.handle(requestFromServer);

    verify(mockTransport).sendMessage(any(Message.class), eq( new Address[] { new InternetAddress("[email protected]") } ));
    verify(mockTransport, times(1)).connect(eq("test-smtp-host"), eq("test-smtp-username"), eq("test-smtp-password"));
    verify(mockTransport, times(1)).close();
    verifyNoMoreInteractions(mockTransport);
}
 
开发者ID:gocd-contrib,项目名称:email-notifier,代码行数:18,代码来源:EmailNotificationPluginImplUnitTest.java


示例4: testMultipleEmailAddressSendsEmail

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Test
public void testMultipleEmailAddressSendsEmail() throws Exception {
    settingsResponseMap.put("receiver_email_id", "[email protected], [email protected]");

    GoApiResponse settingsResponse = testSettingsResponse();

    when(goApplicationAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);

    GoPluginApiRequest requestFromServer = testStageChangeRequestFromServer();

    emailNotificationPlugin.handle(requestFromServer);

    verify(mockTransport).sendMessage(any(Message.class), eq( new Address[] { new InternetAddress("[email protected]") } ));
    verify(mockTransport).sendMessage(any(Message.class), eq( new Address[] { new InternetAddress("[email protected]") } ));
    verify(mockTransport, times(2)).connect(eq("test-smtp-host"), eq("test-smtp-username"), eq("test-smtp-password"));
    verify(mockTransport, times(2)).close();
    verifyNoMoreInteractions(mockTransport);
}
 
开发者ID:gocd-contrib,项目名称:email-notifier,代码行数:19,代码来源:EmailNotificationPluginImplUnitTest.java


示例5: shouldHandleExceptionThrownByProcessor

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Test
public void shouldHandleExceptionThrownByProcessor() throws Exception {
    String api = "api-uri";
    GoPluginApiRequestProcessor processor = mock(GoPluginApiRequestProcessor.class);
    GoApiRequest goApiRequest = mock(GoApiRequest.class);
    GoPluginDescriptor descriptor = mock(GoPluginDescriptor.class);
    when(goApiRequest.api()).thenReturn(api);
    Throwable cause = new RuntimeException("error");
    when(processor.process(descriptor, goApiRequest)).thenThrow(cause);

    PluginRequestProcessorRegistry pluginRequestProcessorRegistry = new PluginRequestProcessorRegistry();
    pluginRequestProcessorRegistry.registerProcessorFor(api, processor);
    PluginAwareDefaultGoApplicationAccessor accessor= new PluginAwareDefaultGoApplicationAccessor(descriptor, pluginRequestProcessorRegistry);
    try {
        accessor.submit(goApiRequest);
    } catch (Exception e) {
        assertThat(e.getMessage(), is(String.format("Error while processing request api %s", api)));
        assertThat(e.getCause(), is(cause));
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:21,代码来源:PluginAwareDefaultGoApplicationAccessorTest.java


示例6: process

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Override
public GoApiResponse process(GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    try {
        String version = goPluginApiRequest.apiVersion();
        if (!goSupportedVersions.contains(version)) {
            throw new RuntimeException(String.format("Unsupported '%s' API version: %s. Supported versions: %s", goPluginApiRequest.api(), version, goSupportedVersions));
        }

        if (goPluginApiRequest.api().equals(PUT_INTO_SESSION)) {
            return handleSessionPutRequest(goPluginApiRequest);
        }
        if (goPluginApiRequest.api().equals(GET_FROM_SESSION)) {
            return handleSessionGetRequest(goPluginApiRequest);
        }
        if (goPluginApiRequest.api().equals(REMOVE_FROM_SESSION)) {
            return handleSessionRemoveRequest(goPluginApiRequest);
        }
    } catch (Exception e) {
        LOGGER.error("Error occurred while authenticating user", e);
    }
    return new DefaultGoApiResponse(500);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:23,代码来源:SessionRequestProcessor.java


示例7: process

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Override
public GoApiResponse process(GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    try {
        GoPluginExtension extension = extensionFor(pluginDescriptor.id());

        PluginSettings pluginSettings = pluginSettingsFor(pluginDescriptor.id());

        DefaultGoApiResponse response = new DefaultGoApiResponse(200);
        response.setResponseBody(extension.pluginSettingsJSON(pluginDescriptor.id(), pluginSettings.getSettingsAsKeyValuePair()));

        return response;
    } catch (Exception e) {
        LOGGER.error(format("Error processing PluginSettings request from plugin: %s.", pluginDescriptor.id()), e);

        DefaultGoApiResponse errorResponse = new DefaultGoApiResponse(400);
        errorResponse.setResponseBody(format("Error while processing get PluginSettings request - %s", e.getMessage()));

        return errorResponse;
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:21,代码来源:PluginSettingsRequestProcessor.java


示例8: process

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Override
public GoApiResponse process(final GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    switch (goPluginApiRequest.api()) {
        case PROCESS_DISABLE_AGENTS:
            Collection<AgentMetadata> agentsToDisable = elasticAgentExtension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).deleteAndDisableAgentRequestBody(goPluginApiRequest.requestBody());
            if (agentsToDisable.isEmpty()) {
                return new DefaultGoApiResponse(200);
            }
            return processDisableAgent(pluginDescriptor, goPluginApiRequest);
        case PROCESS_DELETE_AGENTS:
            Collection<AgentMetadata> agentsToDelete = elasticAgentExtension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).deleteAndDisableAgentRequestBody(goPluginApiRequest.requestBody());
            if (agentsToDelete.isEmpty()) {
                return new DefaultGoApiResponse(200);
            }
            return processDeleteAgent(pluginDescriptor, goPluginApiRequest);
        case REQUEST_SERVER_LIST_AGENTS:
            return processListAgents(pluginDescriptor, goPluginApiRequest);
        default:
            return DefaultGoApiResponse.error("Illegal api request");
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:22,代码来源:ElasticAgentRequestProcessor.java


示例9: processListAgents

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
private GoApiResponse processListAgents(GoPluginDescriptor pluginDescriptor, GoApiRequest goPluginApiRequest) {
    LOGGER.debug("Listing agents for plugin {}", pluginDescriptor.id());
    List<ElasticAgentMetadata> elasticAgents = agentService.allElasticAgents().get(pluginDescriptor.id());

    Collection<AgentMetadata> metadata;
    if (elasticAgents == null) {
        metadata = new ArrayList<>();
    } else {
        metadata = elasticAgents.stream().map(new Function<ElasticAgentMetadata, AgentMetadata>() {
            @Override
            public AgentMetadata apply(ElasticAgentMetadata obj) {
                return toAgentMetadata(obj);
            }
        }).collect(Collectors.toList());
    }

    String responseBody = elasticAgentExtension.getElasticAgentMessageConverter(goPluginApiRequest.apiVersion()).listAgentsResponseBody(metadata);
    return DefaultGoApiResponse.success(responseBody);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:ElasticAgentRequestProcessor.java


示例10: createGoApiRequest

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
private GoApiRequest createGoApiRequest(final String api, final String responseBody) {
    return new GoApiRequest() {
        @Override
        public String api() {
            return api;
        }

        @Override
        public String apiVersion() {
            return "1.0";
        }

        @Override
        public GoPluginIdentifier pluginIdentifier() {
            return getGoPluginIdentifier();
        }

        @Override
        public Map<String, String> requestParameters() {
            return null;
        }

        @Override
        public Map<String, String> requestHeaders() {
            return null;
        }

        @Override
        public String requestBody() {
            return responseBody;
        }
    };
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:34,代码来源:YamlConfigPlugin.java


示例11: setUp

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Before
public void setUp() throws IOException {
    plugin = new YamlConfigPlugin();
    goAccessor = mock(GoApplicationAccessor.class);
    plugin.initializeGoApplicationAccessor(goAccessor);
    GoApiResponse settingsResponse = DefaultGoApiResponse.success("{}");
    when(goAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);
    parser = new JsonParser();
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:10,代码来源:YamlConfigPluginIntegrationTest.java


示例12: shouldTalkToGoApplicationAccessorToGetPluginSettings

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Test
public void shouldTalkToGoApplicationAccessorToGetPluginSettings() throws UnhandledRequestTypeException {
    GoPluginApiResponse response = parseAndGetResponseForDir(tempDir.getRoot());

    verify(goAccessor, times(1)).submit(any(GoApiRequest.class));
    assertThat(response.responseCode(), is(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE));
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:8,代码来源:YamlConfigPluginIntegrationTest.java


示例13: shouldRespondSuccessToParseDirectoryRequestWhenPluginHasConfiguration

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
@Test
public void shouldRespondSuccessToParseDirectoryRequestWhenPluginHasConfiguration() throws UnhandledRequestTypeException {
    GoApiResponse settingsResponse = DefaultGoApiResponse.success("{}");
    when(goAccessor.submit(any(GoApiRequest.class))).thenReturn(settingsResponse);

    GoPluginApiResponse response = parseAndGetResponseForDir(tempDir.getRoot());

    verify(goAccessor, times(1)).submit(any(GoApiRequest.class));
    assertThat(response.responseCode(), is(DefaultGoPluginApiResponse.SUCCESS_RESPONSE_CODE));
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:11,代码来源:YamlConfigPluginIntegrationTest.java


示例14: initializeGoApplicationAccessor

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的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


示例15: createPluginScm

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
protected ArtifactoryScmPlugin createPluginScm() {
	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	plugin.initializeGoApplicationAccessor(new GoApplicationAccessor(){
		
		@Override
		public GoApiResponse submit(GoApiRequest request)
		{
			return new DefaultGoApiResponse(200);
		}
	});
	return plugin;
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:13,代码来源:IntegrationTests.java


示例16: createPluginPkg

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
protected ArtifactoryPkgPlugin createPluginPkg() {
	ArtifactoryPkgPlugin plugin = new ArtifactoryPkgPlugin();
	plugin.initializeGoApplicationAccessor(new GoApplicationAccessor(){
		
		@Override
		public GoApiResponse submit(GoApiRequest request)
		{
			return new DefaultGoApiResponse(200);
		}
	});
	return plugin;
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:13,代码来源:IntegrationTests.java


示例17: store

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
private void  store(SocialAuthManager socialAuthManager) {
    Map<String, Object> requestMap = new HashMap<String, Object>();
    requestMap.put("plugin-id", provider.getPluginId());
    Map<String, Object> sessionData = new HashMap<String, Object>();
    String socialAuthManagerStr = serializeObject(socialAuthManager);
    sessionData.put("social-auth-manager", socialAuthManagerStr);
    requestMap.put("session-data", sessionData);
    GoApiRequest goApiRequest = createGoApiRequest(GO_REQUEST_SESSION_PUT, JSONUtils.toJSON(requestMap));
    GoApiResponse response = goApplicationAccessor.submit(goApiRequest);
    // handle error
}
 
开发者ID:gocd-contrib,项目名称:gocd-oauth-login,代码行数:12,代码来源:OAuthLoginPlugin.java


示例18: read

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
private SocialAuthManager read() {
    Map<String, Object> requestMap = new HashMap<String, Object>();
    requestMap.put("plugin-id", provider.getPluginId());
    GoApiRequest goApiRequest = createGoApiRequest(GO_REQUEST_SESSION_GET, JSONUtils.toJSON(requestMap));
    GoApiResponse response = goApplicationAccessor.submit(goApiRequest);
    // handle error
    String responseBody = response.responseBody();
    Map<String, String> sessionData = (Map<String, String>) JSONUtils.fromJSON(responseBody);
    String socialAuthManagerStr = sessionData.get("social-auth-manager");
    return deserializeObject(socialAuthManagerStr);
}
 
开发者ID:gocd-contrib,项目名称:gocd-oauth-login,代码行数:12,代码来源:OAuthLoginPlugin.java


示例19: delete

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
private void delete() {
    Map<String, Object> requestMap = new HashMap<String, Object>();
    requestMap.put("plugin-id", provider.getPluginId());
    GoApiRequest goApiRequest = createGoApiRequest(GO_REQUEST_SESSION_REMOVE, JSONUtils.toJSON(requestMap));
    GoApiResponse response = goApplicationAccessor.submit(goApiRequest);
    // handle error
}
 
开发者ID:gocd-contrib,项目名称:gocd-oauth-login,代码行数:8,代码来源:OAuthLoginPlugin.java


示例20: authenticateUser

import com.thoughtworks.go.plugin.api.request.GoApiRequest; //导入依赖的package包/类
private void authenticateUser(User user) {
    final Map<String, Object> userMap = new HashMap<String, Object>();
    userMap.put("user", getUserMap(user));
    GoApiRequest authenticateUserRequest = createGoApiRequest(GO_REQUEST_AUTHENTICATE_USER, JSONUtils.toJSON(userMap));
    GoApiResponse authenticateUserResponse = goApplicationAccessor.submit(authenticateUserRequest);
    // handle error
}
 
开发者ID:gocd-contrib,项目名称:gocd-oauth-login,代码行数:8,代码来源:OAuthLoginPlugin.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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