// create this new repo type
final RepositoryTemplate template =
(RepositoryTemplate) templateManager.getTemplates().getTemplateById("nexus4807");
template.getConfigurableRepository().setId("peter");
template.getConfigurableRepository().setName("We all love Peter!");
final Repository repository = template.create();
// do some simple assertion
assertThat(repository.getId(), equalTo("peter"));
assertThat(repository.getName(), equalTo("We all love Peter!"));
// assert peter is here simply, by having this below not throw any exception and returning non-null
// note: by interface contract, this method never returns null: either returns value or throws exception
assertThat(repositoryRegistry.getRepository("peter"), notNullValue());
// now drop it
nexusConfiguration.deleteRepository(repository.getId());
// assert peter left the building
try {
repositoryRegistry.getRepository("peter");
Assert.fail("Peter should not be present, he just left!");
}
catch (NoSuchRepositoryException e) {
// good, he left of main entrance
}
// and assert that we really do love Peter
Nexus4807Repository nexus4807Repository = repository.adaptToFacet(Nexus4807Repository.class);
assertThat(nexus4807Repository.isDisposeInvoked(), is(true));
}