Search in sources :

Example 1 with SubscriptionDescriptorFileValidator

use of uk.gov.justice.subscription.file.read.SubscriptionDescriptorFileValidator in project microservice_framework by CJSCommonPlatform.

the class SubscriptionDescriptorFileParserFactory method create.

@Override
public SubscriptionDescriptorFileParser create() {
    final SubscriptionDescriptorFileValidator subscriptionDescriptorFileValidator = new SubscriptionDescriptorFileValidator(new YamlFileToJsonObjectConverter());
    final SubscriptionDescriptorParser subscriptionDescriptorParser = new SubscriptionDescriptorParser(subscriptionDescriptorFileValidator);
    return new SubscriptionDescriptorFileParser(subscriptionDescriptorParser);
}
Also used : SubscriptionDescriptorFileValidator(uk.gov.justice.subscription.file.read.SubscriptionDescriptorFileValidator) YamlFileToJsonObjectConverter(uk.gov.justice.subscription.file.read.YamlFileToJsonObjectConverter) SubscriptionDescriptorParser(uk.gov.justice.subscription.file.read.SubscriptionDescriptorParser)

Example 2 with SubscriptionDescriptorFileValidator

use of uk.gov.justice.subscription.file.read.SubscriptionDescriptorFileValidator in project microservice_framework by CJSCommonPlatform.

the class SubscriptionDescriptorFileValidatorTest method shouldNotThrowExceptionOnCorrectSubscriptionYaml.

@Test
public void shouldNotThrowExceptionOnCorrectSubscriptionYaml() throws IOException {
    try {
        final SubscriptionDescriptorFileValidator subscriptionDescriptorFileValidator = new SubscriptionDescriptorFileValidator(new YamlFileToJsonObjectConverter());
        subscriptionDescriptorFileValidator.validate(getFromClasspath("subscription.yaml"));
    } catch (ValidationException e) {
        fail("Unexpected validation exception");
    }
}
Also used : ValidationException(org.everit.json.schema.ValidationException) SubscriptionDescriptorFileValidator(uk.gov.justice.subscription.file.read.SubscriptionDescriptorFileValidator) YamlFileToJsonObjectConverter(uk.gov.justice.subscription.file.read.YamlFileToJsonObjectConverter) Test(org.junit.Test)

Example 3 with SubscriptionDescriptorFileValidator

use of uk.gov.justice.subscription.file.read.SubscriptionDescriptorFileValidator in project microservice_framework by CJSCommonPlatform.

the class SubscriptionDescriptorParserTest method createParser.

@Before
public void createParser() {
    final YamlFileToJsonObjectConverter yamlFileToJsonObjectConverter = new YamlFileToJsonObjectConverter();
    final SubscriptionDescriptorFileValidator subscriptionDescriptorFileValidator = new SubscriptionDescriptorFileValidator(yamlFileToJsonObjectConverter);
    subscriptionDescriptorParser = new SubscriptionDescriptorParser(subscriptionDescriptorFileValidator);
}
Also used : SubscriptionDescriptorFileValidator(uk.gov.justice.subscription.file.read.SubscriptionDescriptorFileValidator) YamlFileToJsonObjectConverter(uk.gov.justice.subscription.file.read.YamlFileToJsonObjectConverter) SubscriptionDescriptorParser(uk.gov.justice.subscription.file.read.SubscriptionDescriptorParser) Before(org.junit.Before)

Example 4 with SubscriptionDescriptorFileValidator

use of uk.gov.justice.subscription.file.read.SubscriptionDescriptorFileValidator in project microservice_framework by CJSCommonPlatform.

the class SubscriptionDescriptorFileValidatorTest method shouldThrowExceptionOnInCorrectSubscriptionYaml.

@Test
public void shouldThrowExceptionOnInCorrectSubscriptionYaml() {
    try {
        final SubscriptionDescriptorFileValidator subscriptionDescriptorFileValidator = new SubscriptionDescriptorFileValidator(new YamlFileToJsonObjectConverter());
        subscriptionDescriptorFileValidator.validate(getFromClasspath("incorrect-subscription.yaml"));
        fail();
    } catch (ValidationException e) {
        assertThat(e, is(instanceOf(ValidationException.class)));
        assertThat(e.getMessage(), is("#/subscription_descriptor: required key [spec_version] not found"));
    }
}
Also used : ValidationException(org.everit.json.schema.ValidationException) SubscriptionDescriptorFileValidator(uk.gov.justice.subscription.file.read.SubscriptionDescriptorFileValidator) YamlFileToJsonObjectConverter(uk.gov.justice.subscription.file.read.YamlFileToJsonObjectConverter) Test(org.junit.Test)

Aggregations

SubscriptionDescriptorFileValidator (uk.gov.justice.subscription.file.read.SubscriptionDescriptorFileValidator)4 YamlFileToJsonObjectConverter (uk.gov.justice.subscription.file.read.YamlFileToJsonObjectConverter)4 ValidationException (org.everit.json.schema.ValidationException)2 Test (org.junit.Test)2 SubscriptionDescriptorParser (uk.gov.justice.subscription.file.read.SubscriptionDescriptorParser)2 Before (org.junit.Before)1