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


Java GoPluginApiRequest类代码示例

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


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

示例1: shouldAuthenticate

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void shouldAuthenticate() throws Exception {
    final GoPluginApiRequest goApiRequest = mock(GoPluginApiRequest.class);
    final String requestBody = requestJson("username", "password");

    when(goApiRequest.requestBody()).thenReturn(requestBody);
    final User user = new User("username", "displayName", "email");
    when(authenticator.authenticate(Credentials.fromJSON(requestBody), AuthConfig.fromJSONList(requestBody))).thenReturn(user);

    final GoPluginApiResponse response = new UserAuthenticationExecutor(goApiRequest, authenticator).execute();

    assertThat(response.responseCode(), is(200));

    final String expectedResponseBody = "{\n" +
            "  \"roles\": [],\n" +
            "  \"user\": {\n" +
            "    \"username\": \"username\",\n" +
            "    \"display_name\": \"displayName\",\n" +
            "    \"email\": \"email\"\n" +
            "  }\n" +
            "}";

    JSONAssert.assertEquals(expectedResponseBody, response.responseBody(), true);
}
 
开发者ID:gocd,项目名称:gocd-filebased-authentication-plugin,代码行数:25,代码来源:UserAuthenticationExecutorTest.java

示例2: handle

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Override
public GoPluginApiResponse handle(GoPluginApiRequest request) throws UnhandledRequestTypeException {
    String requestName = request.requestName();
    if (requestName.equals(PLUGIN_SETTINGS_GET_CONFIGURATION)) {
        return handleGetPluginSettingsConfiguration();
    } else if (requestName.equals(PLUGIN_SETTINGS_GET_VIEW)) {
        try {
            return handleGetPluginSettingsView();
        } catch (IOException e) {
            return renderJSON(500, String.format("Failed to find template: %s", e.getMessage()));
        }
    } else if (requestName.equals(PLUGIN_SETTINGS_VALIDATE_CONFIGURATION)) {
        return handleValidatePluginSettingsConfiguration(request);
    }
    if ("parse-directory".equals(request.requestName())) {
        return handleParseDirectoryRequest(request);
    }
    throw new UnhandledRequestTypeException(request.requestName());
}
 
开发者ID:tomzo,项目名称:gocd-yaml-config-plugin,代码行数:20,代码来源:YamlConfigPlugin.java

示例3: settingsValidationOk

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void settingsValidationOk() throws Exception {
	String requestJson =
			"{\"plugin-settings\": {"
				+ "\"connectTimeout\": {"
				+ "\"value\": \"5\""
				+ "}, "
				+ "\"proxyUrl\": {"
				+ "\"value\": \"http://proxy.example.com:1234\""
				+ "},"
				+ "\"connPoolSize\": {"
				+ "\"value\": \"200\""
				+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("go.plugin-settings.validate-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().equals("[]"));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:24,代码来源:IntegrationTests.java

示例4: settingsValidationBadTimeout

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void settingsValidationBadTimeout() throws Exception {
	String requestJson =
			"{\"plugin-settings\": {"
				+ "\"connectTimeout\": {"
				+ "\"value\": \"asdf\""
				+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("go.plugin-settings.validate-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"key\":\"connectTimeout\""));
	Assert.assertTrue(response.responseBody().contains("\"message\":\"Invalid timeout value. Must be an integer > 0 or -1.\""));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:19,代码来源:IntegrationTests.java

示例5: settingsValidationBadProxy

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void settingsValidationBadProxy() throws Exception {
	String requestJson =
			"{\"plugin-settings\": {"
				+ "\"proxyUrl\": {"
				+ "\"value\": \"ftp://whatever:anc\""
				+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("go.plugin-settings.validate-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"key\":\"proxyUrl\""));
	Assert.assertTrue(response.responseBody().contains("\"message\":"));
	Assert.assertTrue(response.responseBody().contains("Exception"));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:20,代码来源:IntegrationTests.java

示例6: settingsValidationBadConnPoolSize

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void settingsValidationBadConnPoolSize() throws Exception {
	String requestJson =
			"{\"plugin-settings\": {"
				+ "\"connPoolSize\": {"
				+ "\"value\": \"asdf\""
				+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("go.plugin-settings.validate-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"key\":\"connPoolSize\""));
	Assert.assertTrue(response.responseBody().contains("\"message\":\"Must be an integer\""));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:19,代码来源:IntegrationTests.java

示例7: scmConfig

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmConfig() throws Exception {
	String requestJson =
			"{}"
	;
	GoPluginApiRequest request = createRequest("scm-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);

	Map map = new ObjectMapper().readValue(response.responseBody(), Map.class);
	Map urlMap = (Map) map.get("url");
	Map patternMap = (Map) map.get("pattern");
	Map dummyIdMap = (Map) map.get("dummy_id");

	Assert.assertEquals("url", urlMap.get("display-name"));
	Assert.assertEquals(Boolean.TRUE, urlMap.get("part-of-identity"));

	Assert.assertEquals("filename regex", patternMap.get("display-name"));
	Assert.assertEquals(Boolean.TRUE, dummyIdMap.get("part-of-identity"));

	Assert.assertEquals("dummy id", dummyIdMap.get("display-name"));
	Assert.assertEquals(Boolean.TRUE, dummyIdMap.get("part-of-identity"));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:27,代码来源:IntegrationTests.java

示例8: scmConfigView

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmConfigView() throws Exception {
	String requestJson ="{}";
	GoPluginApiRequest request = createRequest("scm-view", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	System.out.println("got response:");
	System.out.println(response.responseBody());
	System.out.println();

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"template\":\"<div class"));
	Assert.assertTrue(response.responseBody().contains("GOINPUTNAME[url].$error.server"));
	Assert.assertTrue(response.responseBody().contains("GOINPUTNAME[pattern].$error.server"));
	Assert.assertTrue(response.responseBody().contains("GOINPUTNAME[dummy_id].$error.server"));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:19,代码来源:IntegrationTests.java

示例9: scmValidationOk

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationOk() throws Exception {
	String requestJson =
			"{\"scm-configuration\": {"
					+ "\"url\": {"
					+ "\"value\": \"" + APP_URL + "\""
					+ "},"
					+ "\"pattern\": {"
					+ "\"value\": \"abc\""
					+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().equals("[]"));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:21,代码来源:IntegrationTests.java

示例10: scmValidationUrlMissing

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationUrlMissing() throws Exception {
	String requestJson =
			"{\"scm-configuration\": {"
					+ "\"url\": {"
					+ "\"value\": \"\""
					+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"key\":\"url\""));
	Assert.assertTrue(response.responseBody().contains("\"message\":\"URL not specified\""));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:19,代码来源:IntegrationTests.java

示例11: scmValidationUrlBadScheme

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationUrlBadScheme() throws Exception {
	String requestJson =
			"{\"scm-configuration\": {"
					+ "\"url\": {"
					+ "\"value\": \"ftp://foo/bar/\""
					+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"key\":\"url\""));
	Assert.assertTrue(response.responseBody().contains("\"message\":\"URL with unknown scheme\""));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:19,代码来源:IntegrationTests.java

示例12: scmValidationUrlNoTrailingSlash

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationUrlNoTrailingSlash() throws Exception {
	String requestJson =
			"{\"scm-configuration\": {"
					+ "\"url\": {"
					+ "\"value\": \"http://foo/bar\""
					+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"key\":\"url\""));
	Assert.assertTrue(response.responseBody().contains("\"message\":\"URL must end with a slash\""));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:19,代码来源:IntegrationTests.java

示例13: scmValidationInvalidPattern

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void scmValidationInvalidPattern() throws Exception {
	String requestJson =
			"{\"scm-configuration\": {"
					+ "\"pattern\": {"
					+ "\"value\": \"(\""
					+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("validate-scm-configuration", requestJson);

	ArtifactoryScmPlugin plugin = new ArtifactoryScmPlugin();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"key\":\"pattern\""));
	Assert.assertTrue(response.responseBody().contains("\"message\":\"java.util.regex.PatternSyntaxException: Unclosed group near index 1"));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:19,代码来源:IntegrationTests.java

示例14: checkScmConnection

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void checkScmConnection() throws Exception {
	String requestJson =
			"{\"scm-configuration\": {"
					+ "\"url\": {"
					+ "\"value\": \"" + APP_URL + "\""
					+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("check-scm-connection", requestJson);

	ArtifactoryScmPlugin plugin = createPluginScm();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"status\":\"success\""));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:18,代码来源:IntegrationTests.java

示例15: latestRevision

import com.thoughtworks.go.plugin.api.request.GoPluginApiRequest; //导入依赖的package包/类
@Test
public void latestRevision() throws Exception {
	String requestJson =
			"{\"scm-configuration\": {"
					+ "\"url\": {"
					+ "\"value\": \"" + APP_URL + "\""
					+ "}"
			+ "}}"
	;
	GoPluginApiRequest request = createRequest("latest-revision", requestJson);

	ArtifactoryScmPlugin plugin = createPluginScm();
	GoPluginApiResponse response = plugin.handle(request);

	Assert.assertNotNull(response);
	Assert.assertTrue(response.responseBody().contains("\"revision\":{"));
	Assert.assertTrue(response.responseBody().contains("\"revision\":\"1.2.3\""));
	Assert.assertTrue(response.responseBody().contains("\"revisionComment\":\"1.2.3\""));
	Assert.assertTrue(response.responseBody().contains("\"timestamp\":\"2016-01-03T14:15:00.000Z\""));
	Assert.assertTrue(response.responseBody().contains("\"modifiedFiles\":["));
	Assert.assertTrue(response.responseBody().contains("\"fileName\":\"foo##1.2.3.txt\""));
	Assert.assertTrue(response.responseBody().contains("\"action\":\"added\""));

	Assert.assertFalse(response.responseBody().contains("0.5.1"));
	Assert.assertFalse(response.responseBody().contains("0.9.5"));
}
 
开发者ID:cnenning,项目名称:go-artifactory-scm-plugin,代码行数:27,代码来源:IntegrationTests.java


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