Search in sources :

Example 1 with ResourceValidator

use of io.fabric8.maven.core.util.validator.ResourceValidator in project fabric8-maven-plugin by fabric8io.

the class ResourceValidatorTest method testValidKubernetesResourcesDirectory.

@Test
public void testValidKubernetesResourcesDirectory() throws IOException, URISyntaxException {
    // Given
    URL fileUrl = ResourceValidatorTest.class.getResource("/validations/kubernetes");
    // When
    ResourceValidator resourceValidator = new ResourceValidator(Paths.get(fileUrl.toURI()).toFile(), ResourceClassifier.KUBERNETES, logger);
    int resources = resourceValidator.validate();
    // Then
    Assert.assertEquals(2, resources);
}
Also used : ResourceValidator(io.fabric8.maven.core.util.validator.ResourceValidator) URL(java.net.URL) Test(org.junit.Test)

Example 2 with ResourceValidator

use of io.fabric8.maven.core.util.validator.ResourceValidator in project fabric8-maven-plugin by fabric8io.

the class ResourceValidatorTest method testInvalidKubernetesPodSpec.

@Test
public void testInvalidKubernetesPodSpec() throws IOException, URISyntaxException {
    // Given
    URL fileUrl = ResourceValidatorTest.class.getResource("/validations/kubernetes-deploy-invalid.yml");
    // When
    ResourceValidator resourceValidator = new ResourceValidator(Paths.get(fileUrl.toURI()).toFile(), ResourceClassifier.KUBERNETES, logger);
    // Then
    thrown.expect(ConstraintViolationException.class);
    thrown.expect(Matchers.hasProperty("constraintViolations", IsCollectionWithSize.hasSize(2)));
    // On
    resourceValidator.validate();
}
Also used : ResourceValidator(io.fabric8.maven.core.util.validator.ResourceValidator) URL(java.net.URL) Test(org.junit.Test)

Example 3 with ResourceValidator

use of io.fabric8.maven.core.util.validator.ResourceValidator in project fabric8-maven-plugin by fabric8io.

the class ResourceValidatorTest method testValidOpenShiftResources.

@Test
public void testValidOpenShiftResources() throws IOException, URISyntaxException {
    // Given
    URL fileUrl = ResourceValidatorTest.class.getResource("/validations/openshift-deploymentconfig.yml");
    // When
    ResourceValidator resourceValidator = new ResourceValidator(Paths.get(fileUrl.toURI()).toFile(), ResourceClassifier.OPENSHIFT, logger);
    int resources = resourceValidator.validate();
    // Then
    Assert.assertEquals(1, resources);
}
Also used : ResourceValidator(io.fabric8.maven.core.util.validator.ResourceValidator) URL(java.net.URL) Test(org.junit.Test)

Example 4 with ResourceValidator

use of io.fabric8.maven.core.util.validator.ResourceValidator in project fabric8-maven-plugin by fabric8io.

the class ResourceValidatorTest method testValidOpenshiftResourcesDirectory.

@Test
public void testValidOpenshiftResourcesDirectory() throws IOException, URISyntaxException {
    // Given
    URL fileUrl = ResourceValidatorTest.class.getResource("/validations/openshift");
    // When
    ResourceValidator resourceValidator = new ResourceValidator(Paths.get(fileUrl.toURI()).toFile(), ResourceClassifier.OPENSHIFT, logger);
    int resources = resourceValidator.validate();
    // Then
    Assert.assertEquals(2, resources);
}
Also used : ResourceValidator(io.fabric8.maven.core.util.validator.ResourceValidator) URL(java.net.URL) Test(org.junit.Test)

Example 5 with ResourceValidator

use of io.fabric8.maven.core.util.validator.ResourceValidator in project fabric8-maven-plugin by fabric8io.

the class ResourceValidatorTest method testInvalidOpenshiftDeployConfig.

@Test
public void testInvalidOpenshiftDeployConfig() throws IOException, URISyntaxException {
    // Given
    URL fileUrl = ResourceValidatorTest.class.getResource("/validations/openshift-invalid-deploymentconfig.yml");
    // When
    ResourceValidator resourceValidator = new ResourceValidator(Paths.get(fileUrl.toURI()).toFile(), ResourceClassifier.OPENSHIFT, logger);
    // Then
    thrown.expect(ConstraintViolationException.class);
    thrown.expect(Matchers.hasProperty("constraintViolations", IsCollectionWithSize.hasSize(1)));
    // On
    resourceValidator.validate();
}
Also used : ResourceValidator(io.fabric8.maven.core.util.validator.ResourceValidator) URL(java.net.URL) Test(org.junit.Test)

Aggregations

ResourceValidator (io.fabric8.maven.core.util.validator.ResourceValidator)6 URL (java.net.URL)6 Test (org.junit.Test)6