Search in sources :

Example 6 with ValidationResult

use of org.commonjava.indy.promote.model.ValidationResult in project indy by Commonjava.

the class NoPreExistingPaths_GroupWithOneOfTwoHosts_RuleTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    String deploy = "org/foo/valid/1.1/valid-1.1.pom";
    deployResource(hostTarget1.getKey(), deploy, PREFIX + "valid.pom.xml");
    try (InputStream stream = client.content().get(hostTarget1.getKey(), deploy)) {
        String retrieved = IOUtils.toString(stream);
        assertThat(deploy + " invalid from: " + hostTarget1.getKey(), retrieved, equalTo(resourceToString(PREFIX + "valid.pom.xml")));
    }
    deployResource(hostTarget2.getKey(), deploy, PREFIX + "valid.pom.xml");
    try (InputStream stream = client.content().get(hostTarget2.getKey(), deploy)) {
        String retrieved = IOUtils.toString(stream);
        assertThat(deploy + " invalid from: " + hostTarget2.getKey(), retrieved, equalTo(resourceToString(PREFIX + "valid.pom.xml")));
    }
    GroupPromoteRequest request = new GroupPromoteRequest(hostTarget1.getKey(), target.getName());
    GroupPromoteResult result = module.promoteToGroup(request);
    assertThat(result, notNullValue());
    assertThat(result.getValidations(), notNullValue());
    assertThat(result.getValidations().isValid(), equalTo(true));
    //        target.addConstituent( hostTarget1 );
    //        client.stores().update( target, "update target" );
    //        try (InputStream stream = client.content().get( target.getKey(), deploy ))
    //        {
    //            String retrieved = IOUtils.toString( stream );
    //            assertThat( deploy + " invalid from: " + target.getKey(), retrieved,
    //                        equalTo( resourceToString( PREFIX + "valid.pom.xml" ) ) );
    //        }
    //
    //        deployResource( deploy, PREFIX + "valid.pom.xml" );
    waitForEventPropagation();
    request = new GroupPromoteRequest(hostTarget2.getKey(), target.getName());
    result = module.promoteToGroup(request);
    assertThat(result, notNullValue());
    ValidationResult validations = result.getValidations();
    assertThat(validations, notNullValue());
    Map<String, String> validatorErrors = validations.getValidatorErrors();
    assertThat(validatorErrors, notNullValue());
    System.out.println(validatorErrors);
    String errors = validatorErrors.get(RULE);
    assertThat(errors, notNullValue());
    System.out.println(validatorErrors);
    assertThat(errors.contains(deploy), equalTo(true));
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) InputStream(java.io.InputStream) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) ValidationResult(org.commonjava.indy.promote.model.ValidationResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 7 with ValidationResult

use of org.commonjava.indy.promote.model.ValidationResult in project indy by Commonjava.

the class NoPreExistingPaths_RuleTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    String invalid = "org/foo/invalid/1/invalid-1.pom";
    String valid = "org/foo/valid/1.1/valid-1.1.pom";
    String content = "this is some content";
    deployResource(other.getKey(), invalid, PREFIX + "invalid.pom.xml");
    try (InputStream stream = client.content().get(other.getKey(), invalid)) {
        String retrieved = IOUtils.toString(stream);
        assertThat(invalid + " invalid from: " + other.getKey(), retrieved, equalTo(resourceToString(PREFIX + "invalid.pom.xml")));
    }
    deployResource(invalid, PREFIX + "invalid.pom.xml");
    deployResource(valid, PREFIX + "valid.pom.xml");
    waitForEventPropagation();
    GroupPromoteRequest request = new GroupPromoteRequest(source.getKey(), target.getName());
    GroupPromoteResult result = module.promoteToGroup(request);
    assertThat(result, notNullValue());
    ValidationResult validations = result.getValidations();
    assertThat(validations, notNullValue());
    Map<String, String> validatorErrors = validations.getValidatorErrors();
    assertThat(validatorErrors, notNullValue());
    System.out.println(validatorErrors);
    String errors = validatorErrors.get(RULE);
    assertThat(errors, notNullValue());
    System.out.println(validatorErrors);
    assertThat(errors.contains(valid), equalTo(false));
    assertThat(errors.contains(invalid), equalTo(true));
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) ValidationResult(org.commonjava.indy.promote.model.ValidationResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 8 with ValidationResult

use of org.commonjava.indy.promote.model.ValidationResult in project indy by Commonjava.

the class NoSnapshots_DependencyVersion_RuleTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    String invalid = "org/foo/invalid/1/invalid-1.pom";
    String valid = "org/foo/valid/1.1/valid-1.1.pom";
    deploy(invalid, "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>invalid</artifactId><version>1</version><dependencies>" + "<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>" + "<version>1.0-SNAPSHOT</version></dependency></dependencies></project>");
    deploy(valid, "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>valid</artifactId><version>1.1</version><dependencies>\"\n" + "                + \"<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>\"\n" + "                + \"<version>1.0</version></dependency></dependencies></project>");
    waitForEventPropagation();
    GroupPromoteRequest request = new GroupPromoteRequest(source.getKey(), target.getName());
    GroupPromoteResult result = module.promoteToGroup(request);
    assertThat(result, notNullValue());
    ValidationResult validations = result.getValidations();
    assertThat(validations, notNullValue());
    Map<String, String> validatorErrors = validations.getValidatorErrors();
    assertThat(validatorErrors, notNullValue());
    System.out.println(validatorErrors);
    String errors = validatorErrors.get(RULE);
    assertThat(errors, notNullValue());
    System.out.println(validatorErrors);
    assertThat(errors.contains(valid), equalTo(false));
    assertThat(errors.contains(invalid), equalTo(true));
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) ValidationResult(org.commonjava.indy.promote.model.ValidationResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 9 with ValidationResult

use of org.commonjava.indy.promote.model.ValidationResult in project indy by Commonjava.

the class NoVersionRanges_DependencyVersion_RuleTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    String invalid = "org/foo/invalid/1/invalid-1.pom";
    String valid = "org/foo/valid/1.1/valid-1.1.pom";
    deploy(invalid, "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>invalid</artifactId><version>1</version><dependencies>" + "<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>" + "<version>[1.0,1.1]</version></dependency></dependencies></project>");
    deploy(valid, "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>valid</artifactId><version>1.1</version><dependencies>\"\n" + "                + \"<dependency><groupId>org.bar</groupId><artifactId>dep</artifactId>\"\n" + "                + \"<version>1.0</version></dependency></dependencies></project>");
    waitForEventPropagation();
    GroupPromoteRequest request = new GroupPromoteRequest(source.getKey(), target.getName());
    GroupPromoteResult result = module.promoteToGroup(request);
    assertThat(result, notNullValue());
    ValidationResult validations = result.getValidations();
    assertThat(validations, notNullValue());
    Map<String, String> validatorErrors = validations.getValidatorErrors();
    assertThat(validatorErrors, notNullValue());
    System.out.println(validatorErrors);
    String errors = validatorErrors.get(RULE);
    assertThat(errors, notNullValue());
    System.out.println(validatorErrors);
    assertThat(errors.contains(valid), equalTo(false));
    assertThat(errors.contains(invalid), equalTo(true));
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) ValidationResult(org.commonjava.indy.promote.model.ValidationResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 10 with ValidationResult

use of org.commonjava.indy.promote.model.ValidationResult in project indy by Commonjava.

the class ParsablePomRuleTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    String invalid = "org/foo/invalid/1/invalid-1.pom";
    String valid = "org/foo/valid/1/valid-1.pom";
    deploy(invalid, "This is not parsable");
    deploy(valid, "<?xml version=\"1.0\"?>\n<project><modelVersion>4.0.0</modelVersion><groupId>org.foo</groupId>" + "<artifactId>valid</artifactId><version>1</version></project>");
    waitForEventPropagation();
    GroupPromoteRequest request = new GroupPromoteRequest(source.getKey(), target.getName());
    GroupPromoteResult result = module.promoteToGroup(request);
    assertThat(result, notNullValue());
    ValidationResult validations = result.getValidations();
    assertThat(validations, notNullValue());
    Map<String, String> validatorErrors = validations.getValidatorErrors();
    assertThat(validatorErrors, notNullValue());
    System.out.println(validatorErrors);
    String errors = validatorErrors.get(RULE);
    assertThat(errors, notNullValue());
    System.out.println(validatorErrors);
    assertThat(errors.contains(valid), equalTo(false));
    assertThat(errors.contains(invalid), equalTo(true));
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) ValidationResult(org.commonjava.indy.promote.model.ValidationResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Aggregations

ValidationResult (org.commonjava.indy.promote.model.ValidationResult)20 Test (org.junit.Test)17 GroupPromoteResult (org.commonjava.indy.promote.model.GroupPromoteResult)16 GroupPromoteRequest (org.commonjava.indy.promote.model.GroupPromoteRequest)15 Category (org.junit.experimental.categories.Category)14 InputStream (java.io.InputStream)7 PathsPromoteResult (org.commonjava.indy.promote.model.PathsPromoteResult)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 Group (org.commonjava.indy.model.core.Group)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 IndyDataException (org.commonjava.indy.data.IndyDataException)2 StoreKey (org.commonjava.indy.model.core.StoreKey)2 IndyPromoteClientModule (org.commonjava.indy.promote.client.IndyPromoteClientModule)2 PathsPromoteRequest (org.commonjava.indy.promote.model.PathsPromoteRequest)2 EventMetadata (org.commonjava.maven.galley.event.EventMetadata)2 Transfer (org.commonjava.maven.galley.model.Transfer)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)1 ChangeSummary (org.commonjava.indy.audit.ChangeSummary)1 IndyClientException (org.commonjava.indy.client.core.IndyClientException)1