IdentifierUtils { public static URI generateIdentifier(URI classUri) { Objects.requireNonNull(classUri); if (classUri.getFragment() != null) { return URI.create(classUri.toString() + "_instance" + RANDOM.nextInt()); } else { String base = classUri.toString(); if (base.endsWith("/")) { return URI.create(base + "instance" + RANDOM.nextInt()); } else { return URI.create(base + "/instance" + RANDOM.nextInt()); } } } private  IdentifierUtils(); static URI generateIdentifier(URI classUri); static boolean isResourceIdentifier(Object value);  }
@Test void generateIdentifierAppendsInstanceIdentifierToUriWithHashFragment() { final URI clsUri = URI.create("http: final URI result = IdentifierUtils.generateIdentifier(clsUri); assertThat(result.toString(), containsString("_instance")); }
@Test void generateIdentifierAppendsIdentifierToUriEndingWithSlash() { final URI clsUri = URI.create(URI_WITH_SLASH); final URI result = IdentifierUtils.generateIdentifier(clsUri); assertThat(result.toString(), containsString("/instance")); }
@Test void generateIdentifierAppendsIdentifierWithSlashToUriWithoutHashFragment() { final URI clsUri = URI.create(URI_WITH_SLASH); final URI result = IdentifierUtils.generateIdentifier(clsUri); assertThat(result.toString(), containsString("/instance")); }