Added test
This commit is contained in:
parent
db18c24e5f
commit
74581f132e
|
@ -0,0 +1,49 @@
|
||||||
|
package org.gcube.informationsystem.resourceregistry.er;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
|
||||||
|
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||||
|
import org.gcube.informationsystem.types.TypeBinder;
|
||||||
|
import org.gcube.informationsystem.utils.discovery.ISMDiscovery;
|
||||||
|
import org.gcube.informationsystem.utils.discovery.RegistrationProvider;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
public class DiscoveryTest {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(DiscoveryTest.class);
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void discover() throws Exception {
|
||||||
|
ServiceLoader<? extends RegistrationProvider> regsitrationProviders = ServiceLoader
|
||||||
|
.load(RegistrationProvider.class);
|
||||||
|
List<Package> packages = new ArrayList<>();
|
||||||
|
for(RegistrationProvider registrationProvider : regsitrationProviders) {
|
||||||
|
packages.addAll(registrationProvider.getPackagesToRegister());
|
||||||
|
}
|
||||||
|
Package[] packagesArray = packages.stream().toArray(Package[]::new);
|
||||||
|
|
||||||
|
ISMDiscovery<Resource> resourceDiscovery = new ISMDiscovery<>(Resource.class);
|
||||||
|
Arrays.stream(packagesArray).forEach(p -> resourceDiscovery.addPackage(p));
|
||||||
|
resourceDiscovery.discover();
|
||||||
|
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
stringBuilder.append("[");
|
||||||
|
boolean first = true;
|
||||||
|
for (Class<Resource> resource : resourceDiscovery.getDiscovered()) {
|
||||||
|
if(first) {
|
||||||
|
first = false;
|
||||||
|
}else {
|
||||||
|
stringBuilder.append(",");
|
||||||
|
}
|
||||||
|
stringBuilder.append(TypeBinder.serializeType(resource));
|
||||||
|
}
|
||||||
|
stringBuilder.append("]");
|
||||||
|
logger.debug(stringBuilder.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue