本文整理汇总了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"));
}
示例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
}
示例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);
}
示例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);
}
示例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));
}
}
示例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);
}
示例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;
}
}
示例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");
}
}
示例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);
}
示例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;
}
};
}
示例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();
}
示例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));
}
示例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));
}
示例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);
}
示例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;
}