Search in sources :

Example 1 with CRParseResult

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"));
}
Also used : CRParseResult(com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with CRParseResult

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());
}
Also used : CRParseResult(com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult) Collection(java.util.Collection) ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) File(java.io.File) Test(org.junit.Test)

Example 3 with CRParseResult

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);
}
Also used : CRParseResult(com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult) ConfigRepoExtension(com.thoughtworks.go.plugin.access.configrepo.ConfigRepoExtension) Collection(java.util.Collection) ErrorCollection(com.thoughtworks.go.plugin.access.configrepo.ErrorCollection) Before(org.junit.Before)

Example 4 with CRParseResult

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);
}
Also used : CRParseResult(com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult) Test(org.junit.Test)

Example 5 with CRParseResult

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());
}
Also used : CRParseResult(com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

CRParseResult (com.thoughtworks.go.plugin.access.configrepo.contract.CRParseResult)8 Test (org.junit.Test)5 Matchers.anyString (org.mockito.Matchers.anyString)3 ErrorCollection (com.thoughtworks.go.plugin.access.configrepo.ErrorCollection)2 Collection (java.util.Collection)2 ConfigRepoExtension (com.thoughtworks.go.plugin.access.configrepo.ConfigRepoExtension)1 CRConfigurationProperty (com.thoughtworks.go.plugin.access.configrepo.contract.CRConfigurationProperty)1 ParseDirectoryResponseMessage (com.thoughtworks.go.plugin.access.configrepo.messages.ParseDirectoryResponseMessage)1 File (java.io.File)1 Before (org.junit.Before)1