### Question:
AAIFluentTypeReverseLookup { public AAIObjectType fromName(String name, String uri) { String className = CaseFormat.LOWER_HYPHEN.to(CaseFormat.UPPER_CAMEL, name); uri = uri.replaceFirst(".*?/v\\d+", ""); try { Class<? extends GraphInventoryFluentType.Info> clazz = (Class<? extends GraphInventoryFluentType.Info>) Class .forName("org.onap.aaiclient.client.generated.fluentbuilders." + className + "$Info"); GraphInventoryFluentType.Info type = clazz.getConstructor().newInstance(); Optional<String> parentTemplate = findParentPath(type, uri); if (parentTemplate.isPresent()) { return new AAIObjectType(parentTemplate.get(), type.getPartialUri(), type.getName(), false); } else { return AAIObjectType.fromTypeName(name); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) { } return AAIObjectType.UNKNOWN; }  AAIObjectType fromName(String name, String uri);  }### Answer:
@Test public void reverseParseEntryUri() { String cloudRegion = "http: String newvce = "/aai/v9/network/newvces/newvce/{vnf-id2}"; AAIFluentTypeReverseLookup lookup = new AAIFluentTypeReverseLookup(); AAIObjectType type = lookup.fromName("cloud-region", cloudRegion); assertEquals("cloud-region", type.typeName()); assertEquals("/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}", type.partialUri()); assertEquals("/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}", type.uriTemplate()); type = lookup.fromName("newvce", newvce); assertEquals("newvce", type.typeName()); assertEquals("/newvces/newvce/{vnf-id2}", type.partialUri()); assertEquals("/network/newvces/newvce/{vnf-id2}", type.uriTemplate()); type = lookup.fromName("unknown-type-of-something", "/some/endpoint"); assertEquals("unknown", type.typeName()); }
@Test public void reverseParseTest() { String pserverParent = "/aai/v9/cloud-infrastructure/pservers/pserver/{hostname}/lag-interfaces/lag-interface/{interface-name}/l-interfaces/l-interface/{l-interface.interface-name}"; String cloudRegionParent = "http: String newVceParent = "/network/newvces/newvce/{vnf-id2}/l-interfaces/l-interface/{l-interface.interface-name}"; AAIFluentTypeReverseLookup lookup = new AAIFluentTypeReverseLookup(); AAIObjectType type = lookup.fromName("l-interface", pserverParent); assertEquals("l-interface", type.typeName()); assertEquals("/l-interfaces/l-interface/{l-interface.interface-name}", type.partialUri()); assertEquals( "/cloud-infrastructure/pservers/pserver/{hostname}/lag-interfaces/lag-interface/{interface-name}/l-interfaces/l-interface/{l-interface.interface-name}", type.uriTemplate()); type = lookup.fromName("l-interface", cloudRegionParent); assertEquals("l-interface", type.typeName()); assertEquals("/l-interfaces/l-interface/{l-interface.interface-name}", type.partialUri()); assertEquals( "/cloud-infrastructure/cloud-regions/cloud-region/{cloud-owner}/{cloud-region-id}/tenants/tenant/{tenant-id}/vservers/vserver/{vserver-id}/l-interfaces/l-interface/{l-interface.interface-name}", type.uriTemplate()); type = lookup.fromName("l-interface", newVceParent); assertEquals("l-interface", type.typeName()); assertEquals("/l-interfaces/l-interface/{l-interface.interface-name}", type.partialUri()); assertEquals("/network/newvces/newvce/{vnf-id2}/l-interfaces/l-interface/{l-interface.interface-name}", type.uriTemplate()); }