FipScope { public static @CheckForNull String getServerId(@Nonnull String instanceFingerprint, @CheckForNull String description) { String scope = getScopeString(instanceFingerprint, description); if (scope == null) return null; if (!scope.startsWith("server:")) { throw new IllegalArgumentException("Unknown scope of '" + scope + " description " + description); } return scope.substring(7); }  static @Nonnull String getDescription(@Nonnull String instanceFingerprint, @Nonnull Server server); static @CheckForNull String getServerId(@Nonnull String instanceFingerprint, @CheckForNull String description);  }
@Test public void getServerId() { assertEquals("d8eca2df-7795-4069-b2ef-1e2412491345", FipScope.getServerId(FNGRPRNT, REALISTIC_EXAMPLE)); assertNull(FipScope.getServerId(FNGRPRNT, "{ 'jenkins-instance': 'https: assertNull(FipScope.getServerId(FNGRPRNT, "{ [ 'not', 'the', 'json', 'you', 'expect' ] }")); assertNull(FipScope.getServerId(FNGRPRNT, "[ 'not', 'the', 'json', 'you', 'expect' ]")); assertNull(FipScope.getServerId(FNGRPRNT, "Human description")); assertNull(FipScope.getServerId(FNGRPRNT, "")); assertNull(FipScope.getServerId(FNGRPRNT, null)); }