use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class PromoteWithPurgeThenRollbackAsyncTest method run.
@Test
public void run() throws Exception {
PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(getAsyncRequest(new PathsPromoteRequest(source.getKey(), target.getKey()).setPurgeSource(true)));
assertEquals(result.getResultCode(), ACCEPTED);
result = getAsyncPromoteResult(PathsPromoteResult.class);
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
Set<String> pending = result.getPendingPaths();
assertThat(pending == null || pending.isEmpty(), equalTo(true));
Set<String> completed = result.getCompletedPaths();
assertThat(completed, notNullValue());
assertThat(completed.size(), equalTo(2));
assertThat(result.getError(), nullValue());
result = client.module(IndyPromoteClientModule.class).rollbackPathPromote(result);
assertEquals(result.getResultCode(), ACCEPTED);
result = getAsyncPromoteResult(PathsPromoteResult.class);
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
completed = result.getCompletedPaths();
assertThat(completed == null || completed.isEmpty(), equalTo(true));
pending = result.getPendingPaths();
assertThat(pending, notNullValue());
assertThat(pending.size(), equalTo(2));
assertThat(result.getError(), nullValue());
assertThat(client.content().exists(target.getKey().getType(), target.getName(), first), equalTo(false));
assertThat(client.content().exists(target.getKey().getType(), target.getName(), second), equalTo(false));
assertThat(client.content().exists(source.getKey().getType(), source.getName(), first), equalTo(true));
assertThat(client.content().exists(source.getKey().getType(), source.getName(), second), equalTo(true));
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class PromoteAllAsyncTest method run.
@Test
public void run() throws Exception {
PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(getAsyncRequest(new PathsPromoteRequest(source.getKey(), target.getKey())));
assertEquals(result.getResultCode(), ACCEPTED);
result = getAsyncPromoteResult(PathsPromoteResult.class);
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
final Set<String> pending = result.getPendingPaths();
assertThat(pending == null || pending.isEmpty(), equalTo(true));
final Set<String> completed = result.getCompletedPaths();
assertThat(completed, notNullValue());
assertThat(completed.size(), equalTo(2));
assertThat(result.getError(), nullValue());
assertThat(client.content().exists(target.getKey(), first), equalTo(true));
assertThat(client.content().exists(target.getKey(), second), equalTo(true));
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class NoPreExistingPaths_IdempotentPromotion_RuleTest method run.
@Test
public void run() throws Exception {
String path = "org/foo/valid/1.1/valid-1.1.pom";
// Deploy the resource before promotion
deployResource(target.getKey(), path, PREFIX + "valid.pom.xml");
try (InputStream stream = client.content().get(target.getKey(), path)) {
String retrieved = IOUtils.toString(stream);
assertThat(path + " path from: " + target.getKey(), retrieved, equalTo(resourceToString(PREFIX + "valid.pom.xml")));
}
deployResource(path, PREFIX + "valid.pom.xml");
waitForEventPropagation();
// Promotion the same file(with the same checksum)
PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(new PathsPromoteRequest(source.getKey(), target.getKey(), path).setPurgeSource(true));
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
assertThat(result.getError(), nullValue());
Set<String> pending = result.getPendingPaths();
assertThat(pending == null || pending.isEmpty(), equalTo(true));
Set<String> skipped = result.getSkippedPaths();
assertThat(skipped, notNullValue());
assertThat(skipped.size(), equalTo(1));
}
use of org.commonjava.indy.promote.model.PathsPromoteRequest in project indy by Commonjava.
the class ParsablePomRuleByPathTest 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();
PathsPromoteRequest request = new PathsPromoteRequest(source.getKey(), target.getKey());
request.setPaths(new HashSet(Arrays.asList(invalid, valid)));
PathsPromoteResult result = module.promoteByPath(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.PathsPromoteRequest in project indy by Commonjava.
the class PromoteAllWithPurgeTest method run.
@Test
public void run() throws Exception {
final PathsPromoteResult result = client.module(IndyPromoteClientModule.class).promoteByPath(new PathsPromoteRequest(source.getKey(), target.getKey()).setPurgeSource(true));
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget(), equalTo(target.getKey()));
final Set<String> pending = result.getPendingPaths();
assertThat(pending == null || pending.isEmpty(), equalTo(true));
final Set<String> completed = result.getCompletedPaths();
assertThat(completed, notNullValue());
assertThat(completed.size(), equalTo(2));
assertThat(result.getError(), nullValue());
assertThat(client.content().exists(target.getKey().getType(), target.getName(), first), equalTo(true));
assertThat(client.content().exists(target.getKey().getType(), target.getName(), second), equalTo(true));
assertThat(client.content().exists(source.getKey().getType(), source.getName(), first), equalTo(false));
assertThat(client.content().exists(source.getKey().getType(), source.getName(), second), equalTo(false));
}
Aggregations