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


Java GoApiRequest类代码示例

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


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


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