### Question:
ComposerJsonProcessor { public Content mergePackagesJson(final Repository repository, final List<Payload> payloads) throws IOException { Set<String> names = new HashSet<>(); for (Payload payload : payloads) { Map<String, Object> json = parseJson(payload); Map<String, Object> providers = (Map<String, Object>) json.get(PROVIDERS_KEY); names.addAll(providers.keySet()); } return buildPackagesJson(repository, names); } @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 mergePackagesJson() throws Exception { String inputJson1 = readStreamToString(getClass().getResourceAsStream("mergePackagesJson.input1.json")); String inputJson2 = readStreamToString(getClass().getResourceAsStream("mergePackagesJson.input2.json")); String outputJson = readStreamToString(getClass().getResourceAsStream("mergePackagesJson.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.mergePackagesJson(repository, Arrays.asList(payload1, payload2)); assertEquals(outputJson, readStreamToString(output.openInputStream()), true); }