### Question:
ComposerJsonProcessor { public Content mergeProviderJson(final Repository repository, final List<Payload> payloads, final DateTime now) throws IOException { String currentTime = now.withZone(DateTimeZone.UTC).toString(timeFormatter); Map<String, Map<String, Object>> packages = new LinkedHashMap<>(); for (Payload payload : payloads) { Map<String, Object> json = parseJson(payload); if (json.get(PACKAGES_KEY) instanceof Map) { Map<String, Object> packagesMap = (Map<String, Object>) json.get(PACKAGES_KEY); for (String packageName : packagesMap.keySet()) { Map<String, Object> packageVersions = (Map<String, Object>) packagesMap.get(packageName); for (String packageVersion : packageVersions.keySet()) { Map<String, Object> versionInfo = (Map<String, Object>) packageVersions.get(packageVersion); Map<String, Object> distInfo = (Map<String, Object>) versionInfo.get(DIST_KEY); if (distInfo == null) { continue; } if (!packages.containsKey(packageName)) { packages.put(packageName, new LinkedHashMap<>()); } String time = (String) versionInfo.get(TIME_KEY); if (time == null) { time = currentTime; } Map<String, Object> packagesForName = packages.get(packageName); packagesForName.putIfAbsent(packageVersion, buildPackageInfo(repository, packageName, packageVersion, (String) distInfo.get(REFERENCE_KEY), (String) distInfo.get(SHASUM_KEY), (String) distInfo.get(TYPE_KEY), time, versionInfo)); } } } } return new Content(new StringPayload(mapper.writeValueAsString(singletonMap(PACKAGES_KEY, packages)), ContentTypes.APPLICATION_JSON)); } @Inject  ComposerJsonProcessor(final ComposerJsonExtractor composerJsonExtractor); Content generatePackagesFromList(final Repository repository, final Payload payload); Content generatePackagesFromComponents(final Repository repository, final Iterable<Component> components); Payload rewriteProviderJson(final Repository repository, final Payload payload); Content buildProviderJson(final Repository repository,
                                   final StorageTx storageTx,
                                   final Iterable<Component> components); Content mergePackagesJson(final Repository repository, final List<Payload> payloads); Content mergeProviderJson(final Repository repository, final List<Payload> payloads, final DateTime now); String getDistUrl(final String vendor, final String project, final String version, final Payload payload);  }### Answer:
@Test public void mergeProviderJson() throws Exception { DateTime time = new DateTime(1210869000000L, DateTimeZone.forOffsetHours(-4)); String inputJson1 = readStreamToString(getClass().getResourceAsStream("mergeProviderJson.input1.json")); String inputJson2 = readStreamToString(getClass().getResourceAsStream("mergeProviderJson.input2.json")); String outputJson = readStreamToString(getClass().getResourceAsStream("mergeProviderJson.output.json")); when(repository.getUrl()).thenReturn("http: when(payload1.openInputStream()).thenReturn(new ByteArrayInputStream(inputJson1.getBytes(UTF_8))); when(payload2.openInputStream()).thenReturn(new ByteArrayInputStream(inputJson2.getBytes(UTF_8))); ComposerJsonProcessor underTest = new ComposerJsonProcessor(composerJsonExtractor); Payload output = underTest.mergeProviderJson(repository, Arrays.asList(payload1, payload2), time); assertEquals(outputJson, readStreamToString(output.openInputStream()), true); }