IdentifierManager { @Nullable public String getPath(String identifier) { Tree tree = getTree(identifier); return tree != null && tree.exists() ? tree.getPath() : null; } IdentifierManager(Root root); @NotNull static String generateUUID(); @NotNull static String generateUUID(String hint); static boolean isValidUUID(String uuid); @NotNull static String getIdentifier(Tree tree); @Nullable Tree getTree(String identifier); @Nullable String getPath(String identifier); @Nullable String getPath(PropertyState referenceValue); @Nullable String getPath(PropertyValue referenceValue); @NotNull Iterable<String> getReferences(boolean weak, @NotNull Tree tree, @Nullable final String propertyName); @NotNull Iterable<String> getReferences(@NotNull Tree tree, @NotNull final String propertyName,
                                          @NotNull String ntName, boolean weak); @Nullable String resolveUUID(String uuid);  }
@Test public void getPathTest() { assertEquals("/", identifierManager.getPath(ID_ROOT)); assertEquals(PATH_X1, identifierManager.getPath(ID_X1)); assertEquals(PATH_Y1, identifierManager.getPath(ID_Y1)); assertEquals(PATH_Z1, identifierManager.getPath(ID_Z1)); assertNull(identifierManager.getPath(ID_NON_EXISTING)); try { identifierManager.getPath(ID_INVALID); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@Test public void getPathFromPropertyTest() { assertEquals("/y", identifierManager.getPath(createReferenceProperty(UUID_Y))); assertEquals(PATH_Z1, identifierManager.getPath(createReferenceProperty(UUID_Z1))); assertNull(identifierManager.getPath(createReferenceProperty(ID_NON_EXISTING))); assertNull(identifierManager.getPath(createReferenceProperty(ID_INVALID))); try { identifierManager.getPath(PropertyStates.createProperty("any", "any")); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }