### Question:
DomainSchemaHelper { public static String getDataIslandPathFromGroup(PresentationGroupElement group, List<ResourceElement> clientResources, List<String> constantGroupNames){ String result = null; if(group != null){ final List<PresentationElement> elements = group.getElements(); for (PresentationElement element : elements) { if(element instanceof PresentationGroupElement){ result = getDataIslandPathFromGroup((PresentationGroupElement) element, clientResources, constantGroupNames); } else if(element instanceof PresentationSingleElement){ final String dataIslandPathCandidate = getDataIslandPathFromElement((PresentationSingleElement) element, clientResources); if(!constantGroupNames.contains(dataIslandPathCandidate)) { result = dataIslandPathCandidate; } } if(result != null){ break; } } } if(result == null && !constantGroupNames.isEmpty()){ result = getDataIslandPathFromGroup(group, clientResources, new ArrayList<String>()); } return result; }  static T findResourceElement(String resourcePath, List<ResourceElement> resources); static String getDataIslandPathFromElement(PresentationSingleElement element, List<ResourceElement> clientResources); static String getDataIslandPathFromGroup(PresentationGroupElement group, List<ResourceElement> clientResources,
            List<String> constantGroupNames);  }### Answer:
@Test public void getDataIslandPathFromGroup_recursionAndMockedGetDataIslandIdFromElement_correctResult() { final String expectedId = "expected.id"; final ArrayList<ResourceElement> clientResources = new ArrayList<ResourceElement>(); final PresentationSingleElement singleElement = new PresentationSingleElement().setResourcePath(expectedId + ".constantA"); final PresentationSingleElement constant1 = new PresentationSingleElement().setResourcePath("constants1.constantB"); final PresentationSingleElement constant2 = new PresentationSingleElement().setResourcePath("constants2.constantC"); final PresentationGroupElement group = new PresentationGroupElement(); group.setElements(new ArrayList<PresentationElement>() {{ add(new PresentationGroupElement().setElements((List) Arrays.asList( new PresentationSingleElement(), constant1, singleElement, constant2, new PresentationSingleElement()))); }}); final String result = DomainSchemaHelper.getDataIslandPathFromGroup(group, clientResources, Arrays.asList("constants2", "constants1")); assertEquals(result, expectedId); }
@Test public void getDataIslandPathFromGroup_constantsOnly_constantResourcePath() { final PresentationGroupElement group = new PresentationGroupElement(); final String expectedId = "constants"; group.setElements(new ArrayList<PresentationElement>() {{ add(new PresentationGroupElement().setElements((List) Arrays.asList( new PresentationSingleElement().setResourcePath(expectedId + ".constantA"), new PresentationSingleElement().setResourcePath(expectedId + ".constantB"), new PresentationSingleElement().setResourcePath(expectedId + ".constantC"), new PresentationSingleElement().setResourcePath(expectedId + ".constantD")))); }}); final String result = DomainSchemaHelper.getDataIslandPathFromGroup(group, new ArrayList<ResourceElement>(), Arrays.asList("constants")); assertEquals(result, expectedId); }