use of org.folio.okapi.bean.InterfaceDescriptor in project okapi by folio-org.
the class ModuleInterfaceTest method compatibilityTests.
@Test
public void compatibilityTests() {
logger.debug("compatibilityTests()");
InterfaceDescriptor a = new InterfaceDescriptor("m", "3.4.5");
assertFalse(a.isCompatible(new InterfaceDescriptor("somethingelse", "3.4.5")));
assertTrue(a.isCompatible(new InterfaceDescriptor("m", "3.4.5")));
assertFalse(a.isCompatible(new InterfaceDescriptor("m", "2.1.9")));
assertFalse(a.isCompatible(new InterfaceDescriptor("m", "2.1")));
assertFalse(a.isCompatible(new InterfaceDescriptor("m", "9.1.9")));
assertFalse(a.isCompatible(new InterfaceDescriptor("m", "9.1")));
assertTrue(a.isCompatible(new InterfaceDescriptor("m", "3.4")));
assertTrue(a.isCompatible(new InterfaceDescriptor("m", "3.3")));
assertFalse(a.isCompatible(new InterfaceDescriptor("m", "3.5")));
assertTrue(a.isCompatible(new InterfaceDescriptor("m", "3.4.1")));
assertFalse(a.isCompatible(new InterfaceDescriptor("m", "3.4.6")));
assertFalse(a.isCompatible(new InterfaceDescriptor("m", "2.9.2 3.4.6")));
assertTrue(a.isCompatible(new InterfaceDescriptor("m", "2.9.2 3.4.4")));
assertTrue(a.isCompatible(new InterfaceDescriptor("m", "3.4.4 2.9.2")));
assertFalse(a.isCompatible(new InterfaceDescriptor("m", "2.9.2 3.4.6 4.0.0")));
logger.debug("compatibilityTests() ok");
}
use of org.folio.okapi.bean.InterfaceDescriptor in project okapi by folio-org.
the class ModuleInterfaceTest method validateTests.
@Test
public void validateTests() {
logger.debug("validateTests()");
assertFalse(InterfaceDescriptor.validateVersion("1"));
assertFalse(InterfaceDescriptor.validateVersion("1."));
assertTrue(InterfaceDescriptor.validateVersion("1.2"));
assertTrue(InterfaceDescriptor.validateVersion("1.2."));
assertTrue(InterfaceDescriptor.validateVersion("1.2.3"));
assertTrue(InterfaceDescriptor.validateVersion("1.2.3."));
// not an IP!
assertFalse(InterfaceDescriptor.validateVersion("1.2.3.4"));
assertFalse(InterfaceDescriptor.validateVersion("X"));
assertFalse(InterfaceDescriptor.validateVersion("X.Y.X"));
assertFalse(InterfaceDescriptor.validateVersion("1.2.*"));
assertTrue(InterfaceDescriptor.validateVersion("1.2 2.3"));
InterfaceDescriptor mi = new InterfaceDescriptor();
try {
mi.setVersion("1.2.3");
} catch (IllegalArgumentException e) {
fail("Failed to set version: " + e.getMessage());
}
try {
mi.setVersion("XXX");
fail("Managed to set a bad version number");
} catch (IllegalArgumentException e) {
logger.debug("Refused a bad version number 'XXX' as it should");
}
logger.debug("validateTests() ok");
}
use of org.folio.okapi.bean.InterfaceDescriptor in project okapi by folio-org.
the class ModuleInterfaceTest method simpleTests.
@Test
public void simpleTests() {
logger.debug("simpleTests()");
InterfaceDescriptor mi = new InterfaceDescriptor();
// Test defaults
String id = mi.getId();
assertEquals(null, id);
String ver = mi.getVersion();
assertEquals(null, ver);
mi.setId("idhere");
assertEquals("idhere", mi.getId());
mi.setVersion("1.2.3");
assertEquals("1.2.3", mi.getVersion());
mi = new InterfaceDescriptor("hello", "4.5.6");
assertEquals("hello", mi.getId());
assertEquals("4.5.6", mi.getVersion());
try {
mi = new InterfaceDescriptor("fail", "4.x");
fail("Managed to set a bad version number 4.x");
} catch (IllegalArgumentException e) {
// no problem
}
logger.debug("simpleTests() ok");
}
use of org.folio.okapi.bean.InterfaceDescriptor in project okapi by folio-org.
the class TenantManager method listModulesFromInterface.
public void listModulesFromInterface(String tenantId, String interfaceName, String interfaceType, Handler<ExtendedAsyncResult<List<ModuleDescriptor>>> fut) {
tenants.get(tenantId, tres -> {
if (tres.failed()) {
fut.handle(new Failure<>(tres.getType(), tres.cause()));
return;
}
Tenant tenant = tres.result();
List<ModuleDescriptor> mdList = new LinkedList<>();
moduleManager.getEnabledModules(tenant, mres -> {
if (mres.failed()) {
fut.handle(new Failure<>(mres.getType(), mres.cause()));
return;
}
List<ModuleDescriptor> modlist = mres.result();
for (ModuleDescriptor md : modlist) {
for (InterfaceDescriptor provide : md.getProvidesList()) {
if (interfaceName.equals(provide.getId()) && (interfaceType == null || provide.isType(interfaceType))) {
mdList.add(md);
break;
}
}
}
fut.handle(new Success<>(mdList));
});
// modlist
});
// tenant
}
use of org.folio.okapi.bean.InterfaceDescriptor in project okapi by folio-org.
the class TenantManager method listInterfaces.
private void listInterfaces(Tenant tenant, boolean full, String interfaceType, Handler<ExtendedAsyncResult<List<InterfaceDescriptor>>> fut) {
List<InterfaceDescriptor> intList = new LinkedList<>();
moduleManager.getEnabledModules(tenant, mres -> {
if (mres.failed()) {
fut.handle(new Failure<>(mres.getType(), mres.cause()));
return;
}
List<ModuleDescriptor> modlist = mres.result();
Set<String> ids = new HashSet<>();
for (ModuleDescriptor md : modlist) {
for (InterfaceDescriptor provide : md.getProvidesList()) {
if (interfaceType == null || provide.isType(interfaceType)) {
if (full) {
intList.add(provide);
} else {
if (ids.add(provide.getId())) {
InterfaceDescriptor tmp = new InterfaceDescriptor();
tmp.setId(provide.getId());
tmp.setVersion(provide.getVersion());
intList.add(tmp);
}
}
}
}
}
fut.handle(new Success<>(intList));
});
}
Aggregations