Search in sources :

Example 6 with InterfaceDescriptor

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");
}
Also used : InterfaceDescriptor(org.folio.okapi.bean.InterfaceDescriptor) Test(org.junit.Test)

Example 7 with InterfaceDescriptor

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");
}
Also used : InterfaceDescriptor(org.folio.okapi.bean.InterfaceDescriptor) Test(org.junit.Test)

Example 8 with InterfaceDescriptor

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");
}
Also used : InterfaceDescriptor(org.folio.okapi.bean.InterfaceDescriptor) Test(org.junit.Test)

Example 9 with InterfaceDescriptor

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
}
Also used : ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) Tenant(org.folio.okapi.bean.Tenant) LinkedList(java.util.LinkedList) InterfaceDescriptor(org.folio.okapi.bean.InterfaceDescriptor)

Example 10 with InterfaceDescriptor

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));
    });
}
Also used : ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) TenantModuleDescriptor(org.folio.okapi.bean.TenantModuleDescriptor) LinkedList(java.util.LinkedList) InterfaceDescriptor(org.folio.okapi.bean.InterfaceDescriptor) HashSet(java.util.HashSet)

Aggregations

InterfaceDescriptor (org.folio.okapi.bean.InterfaceDescriptor)12 ModuleDescriptor (org.folio.okapi.bean.ModuleDescriptor)7 TenantModuleDescriptor (org.folio.okapi.bean.TenantModuleDescriptor)7 LinkedList (java.util.LinkedList)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ModuleInstance (org.folio.okapi.bean.ModuleInstance)1 PermissionList (org.folio.okapi.bean.PermissionList)1 RoutingEntry (org.folio.okapi.bean.RoutingEntry)1 Tenant (org.folio.okapi.bean.Tenant)1