Search in sources :

Example 1 with GroupPromoteRequest

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

the class IndyPromoteClientModule method promoteToGroup.

public GroupPromoteResult promoteToGroup(final StoreType srcType, final String srcName, final String targetGroup) throws IndyClientException {
    final GroupPromoteRequest req = new GroupPromoteRequest(new StoreKey(srcType, srcName), targetGroup);
    final GroupPromoteResult result = http.postWithResponse(GROUP_PROMOTE_PATH, req, GroupPromoteResult.class, HttpStatus.SC_OK);
    return result;
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) StoreKey(org.commonjava.indy.model.core.StoreKey)

Example 2 with GroupPromoteRequest

use of org.commonjava.indy.promote.model.GroupPromoteRequest 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)

Example 3 with GroupPromoteRequest

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

the class FullRuleStack_GroupWithOneOfTwoHosts_RuleTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    List<String> deploy = Arrays.asList("org/foo/valid/1.1.0-redhat-1/valid-1.1.0-redhat-1.pom", "org/foo/valid/1.1.0-redhat-1/valid-1.1.0-redhat-1.jar", "org/foo/valid/1.1.0-redhat-1/valid-1.1.0-redhat-1-sources.jar", "org/foo/valid/1.1.0-redhat-1/valid-1.1.0-redhat-1-javadoc.jar");
    Stream.of(hostTarget1, hostTarget2).forEach((repo) -> deploy.forEach((path) -> {
        try {
            deployResource(repo.getKey(), path, PREFIX + "valid.pom.xml");
            try (InputStream stream = client.content().get(repo.getKey(), path)) {
                String retrieved = IOUtils.toString(stream);
                assertThat(path + " invalid from: " + repo.getKey(), retrieved, equalTo(resourceToString(PREFIX + "valid.pom.xml")));
            }
        } catch (Exception e) {
            fail("Failed to deploy: " + path + " to: " + repo);
        }
    }));
    // 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");
    deploy.forEach((path) -> {
        try {
            try (InputStream stream = client.content().get(target.getKey(), path)) {
                String retrieved = IOUtils.toString(stream);
                assertThat(path + " invalid from: " + target.getKey(), retrieved, equalTo(resourceToString(PREFIX + "valid.pom.xml")));
            }
        } catch (Exception e) {
            fail("Failed to verify: " + path + " in: " + target.getKey());
        }
    });
    waitForEventPropagation();
    GroupPromoteRequest request = new GroupPromoteRequest(hostTarget2.getKey(), target.getKey());
    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( deploy ), equalTo( true ) );
}
Also used : GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) Arrays(java.util.Arrays) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) ValidationResult(org.commonjava.indy.promote.model.ValidationResult) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) IOException(java.io.IOException) HashMap(java.util.HashMap) Category(org.junit.experimental.categories.Category) Group(org.commonjava.indy.model.core.Group) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) EventDependent(org.commonjava.indy.ftest.core.category.EventDependent) Assert.assertThat(org.junit.Assert.assertThat) IOUtils(org.apache.commons.io.IOUtils) ValidationRuleSet(org.commonjava.indy.promote.model.ValidationRuleSet) List(java.util.List) Stream(java.util.stream.Stream) HostedRepository(org.commonjava.indy.model.core.HostedRepository) CoreServerFixture(org.commonjava.indy.test.fixture.core.CoreServerFixture) Map(java.util.Map) GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) Assert.fail(org.junit.Assert.fail) InputStream(java.io.InputStream) PKG_TYPE_MAVEN(org.commonjava.indy.pkg.PackageTypeConstants.PKG_TYPE_MAVEN) 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) IOException(java.io.IOException) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 4 with GroupPromoteRequest

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

the class RecursiveGroupMetadataFoundAfterMemberPromotedTest method run.

@Test
@Category(EventDependent.class)
public void run() throws Exception {
    assertNullContent(hostedX, PATH);
    assertNullContent(groupA, PATH);
    assertNullContent(groupB, PATH);
    client.content().store(hostedX.getKey(), PATH, new ByteArrayInputStream(HOSTED_X_CONTENT.getBytes("UTF-8")));
    waitForEventPropagation();
    assertContent(hostedX, PATH, HOSTED_X_CONTENT);
    GroupPromoteRequest request = new GroupPromoteRequest(hostedX.getKey(), groupA.getName());
    GroupPromoteResult result = promotions.promoteToGroup(request);
    assertThat(result.succeeded(), equalTo(true));
    waitForEventPropagation();
    // Order is important here...we want to try the most ambitious one first and move down to the simpler cases.
    // This will prevent us from inadvertently triggering metadata aggregation in a lower group that might not
    // happen otherwise.
    assertContent(groupC, PATH, HOSTED_X_CONTENT);
    assertContent(groupB, PATH, HOSTED_X_CONTENT);
    assertContent(groupA, PATH, HOSTED_X_CONTENT);
}
Also used : GroupPromoteRequest(org.commonjava.indy.promote.model.GroupPromoteRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) GroupPromoteResult(org.commonjava.indy.promote.model.GroupPromoteResult) Category(org.junit.experimental.categories.Category) Test(org.junit.Test) AbstractContentManagementTest(org.commonjava.indy.ftest.core.AbstractContentManagementTest)

Example 5 with GroupPromoteRequest

use of org.commonjava.indy.promote.model.GroupPromoteRequest 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)

Aggregations

GroupPromoteRequest (org.commonjava.indy.promote.model.GroupPromoteRequest)32 GroupPromoteResult (org.commonjava.indy.promote.model.GroupPromoteResult)32 Test (org.junit.Test)26 ValidationResult (org.commonjava.indy.promote.model.ValidationResult)18 Category (org.junit.experimental.categories.Category)17 Group (org.commonjava.indy.model.core.Group)11 IndyPromoteClientModule (org.commonjava.indy.promote.client.IndyPromoteClientModule)9 InputStream (java.io.InputStream)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IndyDataException (org.commonjava.indy.data.IndyDataException)3 AbstractContentManagementTest (org.commonjava.indy.ftest.core.AbstractContentManagementTest)3 IOException (java.io.IOException)2 ExecutionException (java.util.concurrent.ExecutionException)2 HostedRepository (org.commonjava.indy.model.core.HostedRepository)2 StoreKey (org.commonjava.indy.model.core.StoreKey)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1