public static void assertState(CommonServicesContext commonServicesContext, InternalServicesContext internalServicesContext, String resourceName, Class<?> resourceContext, boolean withContent) {
ResourcesState resourcesState = new ResourcesState();
resourcesState.setResources(internalServicesContext.getInternalIPResourceService().resourceFindAll().stream()
.map(resource -> {
ResourceState resourceState = new ResourceState(getResourceDetails(resource));
if (withContent) {
IPResource cloned = JsonTools.clone(resource);
cloned.setInternalId(null);
resourceState.setContent(cloned);
}
List<ResourcesStateLink> links = commonServicesContext.getResourceService().linkFindAllByFromResource(resource).stream()
.map(link -> new ResourcesStateLink(link.getA(), getResourceDetails(link.getB())))
.collect(Collectors.toList());
resourceState.setLinks(links);
resourceState.setTags(commonServicesContext.getResourceService().tagFindAllByResource(resource).stream().sorted().collect(Collectors.toList()));
return resourceState;
})
.collect(Collectors.toList()));
resourcesState.sort();
String actualJson = JsonTools.prettyPrintWithoutNulls(resourcesState);
actualJson = actualJson.replaceAll("\\\\n", "\n");
actualJson = actualJson.replaceAll("\\\\t", "\t");
String expectedJson = ResourceTools.getResourceAsString(resourceName, resourceContext);
AssertTools.assertIgnoreLineFeed(expectedJson, actualJson);
}