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;
}
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));
}
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 ) );
}
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);
}
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));
}
Aggregations