GraniteUi { public static @Nullable String getExistingResourceType(@NotNull ResourceResolver resourceResolver, @NotNull String @NotNull... resourceTypes) { for (String path : resourceTypes) { if (resourceResolver.getResource(path) != null) { return path; } } return null; } private  GraniteUi(); static @Nullable Resource getContentResource(@NotNull HttpServletRequest request); static @Nullable Resource getContentResourceOrParent(@NotNull HttpServletRequest request); static @Nullable Page getContentPage(@NotNull HttpServletRequest request); static @Nullable String getExistingResourceType(@NotNull ResourceResolver resourceResolver, @NotNull String @NotNull... resourceTypes);  }
@Test void testGetExistingResourceType() { when(resourceResolver.getResource("/type/1")).thenReturn(resource); assertEquals("/type/1", GraniteUi.getExistingResourceType(resourceResolver, "/type/2", "/type/1")); assertNull(GraniteUi.getExistingResourceType(resourceResolver, "/non/existing")); assertNull(GraniteUi.getExistingResourceType(resourceResolver)); }