use of com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult in project gocd by gocd.
the class JsonMessageHandler1_0Test method shouldErrorWhenMissingTargetVersionInResponse.
@Test
public void shouldErrorWhenMissingTargetVersionInResponse() {
String json = "{\n" + " \"environments\" : [],\n" + " \"pipelines\" : [],\n" + " \"errors\" : []\n" + "}";
CRParseResult result = handler.responseMessageForParseDirectory(json);
assertThat(result.getErrors().getErrorsAsText(), contains("missing 'target_version' field"));
}
use of com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult in project gocd by gocd.
the class GoConfigPluginServiceTest method shouldAskExtensionForPluginImplementationWhenPluginIdSpecified.
@Test
public void shouldAskExtensionForPluginImplementationWhenPluginIdSpecified() throws Exception {
PartialConfigProvider plugin = service.partialConfigProviderFor("plugin-id");
assertThat(plugin instanceof ConfigRepoPlugin, is(true));
CRParseResult loaded = ((ConfigRepoPlugin) plugin).parseDirectory(new File("dir"), mock(Collection.class));
assertSame(environments, parseResult.getEnvironments());
assertSame(pipelines, parseResult.getPipelines());
assertSame(errors, parseResult.getErrors());
}
use of com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult in project gocd by gocd.
the class GoConfigPluginServiceTest method SetUp.
@Before
public void SetUp() {
extension = mock(ConfigRepoExtension.class);
service = new GoConfigPluginService(extension, mock(ConfigCache.class), ConfigElementImplementationRegistryMother.withNoPlugins(), mock(CachedGoConfig.class));
parseResult = new CRParseResult(environments, pipelines, errors);
when(extension.parseDirectory(any(String.class), any(String.class), any(Collection.class))).thenReturn(parseResult);
}
use of com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult in project gocd by gocd.
the class ConfigRepoExtensionTest method shouldTalkToPluginToGetParsedDirectory.
@Test
public void shouldTalkToPluginToGetParsedDirectory() throws Exception {
CRParseResult deserializedResponse = new CRParseResult();
when(jsonMessageHandler.responseMessageForParseDirectory(responseBody)).thenReturn(deserializedResponse);
CRParseResult response = extension.parseDirectory(PLUGIN_ID, "dir", null);
assertRequest(requestArgumentCaptor.getValue(), CONFIG_REPO_EXTENSION, "1.0", ConfigRepoExtension.REQUEST_PARSE_DIRECTORY, null);
verify(jsonMessageHandler).responseMessageForParseDirectory(responseBody);
assertSame(response, deserializedResponse);
}
use of com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult in project gocd by gocd.
the class JsonMessageHandler1_0Test method shouldAppendPluginErrorsToAllErrors.
@Test
public void shouldAppendPluginErrorsToAllErrors() {
String json = "{\n" + " \"target_version\" : 1,\n" + " \"pipelines\" : [],\n" + " \"errors\" : [{\"location\" : \"somewhere\", \"message\" : \"failed to parse pipeline.json\"}]\n" + "}";
CRParseResult result = handler.responseMessageForParseDirectory(json);
assertTrue(result.hasErrors());
}
Aggregations