use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class GroupPromoteAndRollbackTest method run.
@Test
public void run() throws Exception {
GroupPromoteResult result = client.module(IndyPromoteClientModule.class).promoteToGroup(new GroupPromoteRequest(source.getKey(), target.getName()));
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget().getName(), equalTo(target.getName()));
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));
Group g = client.stores().load(StoreType.group, target.getName(), Group.class);
assertThat(g.getConstituents().contains(source.getKey()), equalTo(true));
// now rollback.
result = client.module(IndyPromoteClientModule.class).rollbackGroupPromote(result);
assertThat(result.getError(), nullValue());
// wait for events to propagate and remove indexed values.
Thread.sleep(2000);
assertThat(client.content().exists(target.getKey().getType(), target.getName(), first), equalTo(false));
assertThat(client.content().exists(target.getKey().getType(), target.getName(), second), equalTo(false));
g = client.stores().load(StoreType.group, target.getName(), Group.class);
assertThat(g.getConstituents().contains(source.getKey()), equalTo(false));
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class GroupPromoteMatchesSucceedingValidationAsyncTest method run.
@Test
public void run() throws Exception {
GroupPromoteResult result = client.module(IndyPromoteClientModule.class).promoteToGroup(getAsyncRequest(new GroupPromoteRequest(source.getKey(), target.getName())));
assertEquals(result.getResultCode(), ACCEPTED);
result = getAsyncPromoteResult(GroupPromoteResult.class);
assertThat(result.succeeded(), equalTo(true));
assertThat(result.getRequest().getSource(), equalTo(source.getKey()));
assertThat(result.getRequest().getTarget().getName(), equalTo(target.getName()));
assertThat(result.getError(), nullValue());
ValidationResult validations = result.getValidations();
assertThat(validations, notNullValue());
assertThat(validations.isValid(), equalTo(true));
assertThat(client.content().exists(target.getKey().getType(), target.getName(), first), equalTo(true));
assertThat(client.content().exists(target.getKey().getType(), target.getName(), second), equalTo(true));
Group g = client.stores().load(StoreType.group, target.getName(), Group.class);
assertThat(g.getConstituents().contains(source.getKey()), equalTo(true));
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class GroupTest method copyFidelity.
@Test
public void copyFidelity() {
Group src = new Group(GENERIC_PKG_KEY, "test");
src.setMetadata("key", "value");
src.setDescription("some description");
src.setDisableTimeout(500);
src.setDisabled(true);
src.setTransientMetadata("transient", "someval");
src.setPathStyle(PathStyle.hashed);
src.addConstituent(new StoreKey(GENERIC_PKG_KEY, remote, "foo"));
Group target = src.copyOf();
Stream.of(Group.class.getMethods()).filter(m -> m.getName().startsWith("get") && m.isAccessible() && m.getParameterCount() == 0).forEach(m -> {
try {
assertThat(m.getName() + " didn't get copied correctly!", m.invoke(target), equalTo(m.invoke(src)));
} catch (IllegalAccessException e) {
e.printStackTrace();
fail("Failed to invoke: " + m.getName());
} catch (InvocationTargetException e) {
e.printStackTrace();
}
});
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class AbstractCoreUrlsTest method before.
@Before
public void before() throws Exception {
if (!createStandardTestStructures()) {
return;
}
final String changelog = "Create test structures";
final HostedRepository hosted = this.client.stores().create(new HostedRepository(STORE), changelog, HostedRepository.class);
Group g;
if (client.stores().exists(group, PUBLIC)) {
System.out.println("Loading pre-existing public group.");
g = client.stores().load(group, PUBLIC, Group.class);
} else {
System.out.println("Creating new group 'public'");
g = client.stores().create(new Group(PUBLIC), changelog, Group.class);
}
g.setConstituents(Collections.singletonList(hosted.getKey()));
client.stores().update(g, changelog);
}
use of org.commonjava.indy.model.core.Group in project indy by Commonjava.
the class MaintenanceController method getTombstoneStores.
public Set<StoreKey> getTombstoneStores(String packageType) throws IndyDataException {
List<HostedRepository> stores = storeDataManager.query().getAllHostedRepositories(packageType);
Set<StoreKey> tombstoneStores = new HashSet<>();
for (HostedRepository hosted : stores) {
StoreKey key = hosted.getKey();
ConcreteResource root = new ConcreteResource(LocationUtils.toLocation(hosted), PathUtils.ROOT);
String[] files = cacheProvider.list(root);
if (files == null || files.length == 0) {
logger.debug("Empty store: {}", key);
Set<Group> affected = storeDataManager.affectedBy(Arrays.asList(key));
if (affected == null || affected.isEmpty()) {
logger.info("Find tombstone store (no content and not in any group): {}", key);
tombstoneStores.add(key);
}
}
}
return tombstoneStores;
}
Aggregations