Search in sources :

Example 31 with GroupPromoteRequest

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

the class ArtifactRefs_DependencyTwoExtraGroups_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 dep1Pom = "org/bar/dep/1.0/dep-1.0.pom";
    String dep1Jar = "org/bar/dep/1.0/dep-1.0.jar";
    String dep2Pom = "org/blat/dep2/1.0/dep2-1.0.pom";
    String dep2Jar = "org/blat/dep2/1.0/dep2-1.0.jar";
    String content = "this is some content";
    client.content().store(otherSource.getKey(), dep1Pom, new ByteArrayInputStream(content.getBytes()));
    client.content().store(otherSource.getKey(), dep1Jar, new ByteArrayInputStream(content.getBytes()));
    client.content().store(thirdSource.getKey(), dep2Pom, new ByteArrayInputStream(content.getBytes()));
    client.content().store(thirdSource.getKey(), dep2Jar, new ByteArrayInputStream(content.getBytes()));
    InputStream stream = client.content().get(other.getKey(), dep1Pom);
    String retrieved = IOUtils.toString(stream);
    stream.close();
    assertThat(dep1Pom + " invalid from: " + other.getKey(), retrieved, equalTo(content));
    stream = client.content().get(other.getKey(), dep1Jar);
    retrieved = IOUtils.toString(stream);
    stream.close();
    assertThat(dep1Jar + " invalid from: " + other.getKey(), retrieved, equalTo(content));
    deployResource(invalid, PREFIX + "invalid-external-dep.pom.xml");
    deployResource(valid, PREFIX + "valid-two-external-deps.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) 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 32 with GroupPromoteRequest

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

the class IndyPromoteClientModule method promoteToGroup.

public GroupPromoteResult promoteToGroup(final StoreKey src, final String targetGroup) throws IndyClientException {
    final GroupPromoteRequest req = new GroupPromoteRequest(src, 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)

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