Source:
public void shouldGetLargeExportWithStats() throws IOException { int maxFeeds = 10; int maxItems = 1000; for (int j = 0; j < maxFeeds; j++) { List<RawResource> resources = new ArrayList<>(); for (int i = 0; i < maxItems; i++) { RawResource resourceX = new RawResource("F" + j + "L" + i, "Large" + i, "feed" + j, "FOO", null, new ArrayList<>(), new HashMap<>(), new HashMap<>()); resources.add(resourceX); } service.addResource(resources); } int maxTypes = 200; List<ResourceType> resourceTypes = new ArrayList<>(); for (int i = 0; i < maxTypes; i++) { ResourceType typeX = new ResourceType("RT" + i, new ArrayList<>(), new HashMap<>()); resourceTypes.add(typeX); } service.addResourceType(resourceTypes); ByteArrayOutputStream baos = new ByteArrayOutputStream(); service.buildExport(baos); byte[] bytes = baos.toByteArray(); String str = new String(bytes); Inventory export = new ObjectMapper(new JsonFactory()).readValue(str, Inventory.class); assertThat(export).isNotNull(); assertThat(export.getResources()) .hasSize(maxFeeds*maxItems + 6) .extracting(RawResource::getId) .contains("EAP-1", "F0L0", "F5L500", "F9L999"); assertThat(export.getTypes()) .hasSize(maxTypes + 3) .extracting(ResourceType::getId) .contains("EAP", "RT0", "RT100", "RT199"); InventoryHealth health = service.getHealthStatus(); assertThat(health.getInventoryStats()).isNotNull(); assertThat(health.getInventoryStats().getNumberOfResources() > 10000); assertThat(health.getInventoryStats().getNumberOfResourcesInMemory() == 5000); assertThat(health.getDiskStats().getInventoryTotalSpace() > 4000000L); }

Target:
public void shouldGetLargeExportWithStats() throws IOException, InterruptedException { int maxFeeds = 10; int maxItems = 1000; for (int j = 0; j < maxFeeds; j++) { List<RawResource> resources = new ArrayList<>(); for (int i = 0; i < maxItems; i++) { RawResource resourceX = new RawResource("F" + j + "L" + i, "Large" + i, "feed" + j, "FOO", null, new ArrayList<>(), new HashMap<>(), new HashMap<>()); resources.add(resourceX); } service.addResource(resources); } int maxTypes = 200; List<ResourceType> resourceTypes = new ArrayList<>(); for (int i = 0; i < maxTypes; i++) { ResourceType typeX = new ResourceType("RT" + i, new ArrayList<>(), new HashMap<>()); resourceTypes.add(typeX); } service.addResourceType(resourceTypes); ByteArrayOutputStream baos = new ByteArrayOutputStream(); service.buildExport(baos); byte[] bytes = baos.toByteArray(); String str = new String(bytes); Inventory export = new ObjectMapper(new JsonFactory()).readValue(str, Inventory.class); assertThat(export).isNotNull(); assertThat(export.getResources()) .hasSize(maxFeeds*maxItems + 6) .extracting(RawResource::getId) .contains("EAP-1", "F0L0", "F5L500", "F9L999"); assertThat(export.getTypes()) .hasSize(maxTypes + 3) .extracting(ResourceType::getId) .contains("EAP", "RT0", "RT100", "RT199"); InventoryHealth health = service.getHealthStatus(); assertThat(health.getInventoryStats()).isNotNull(); assertThat(health.getInventoryStats().getNumberOfResources()).isGreaterThan(10000); assertThat(health.getInventoryStats().getNumberOfResourcesInMemory()).isEqualTo(5000); assertThat(health.getDiskStats().getInventoryTotalSpace()).isGreaterThan(4000000L); }