### Question:
ComposerJsonProcessor { public Content generatePackagesFromComponents(final Repository repository, final Iterable<Component> components) throws IOException { return buildPackagesJson(repository, StreamSupport.stream(components.spliterator(), false) .map(component -> component.group() + "/" + component.name()).collect(Collectors.toSet())); } @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 generatePackagesFromComponents() throws Exception { String packagesJson = readStreamToString(getClass().getResourceAsStream("generatePackagesFromComponents.json")); when(repository.getUrl()).thenReturn("http: when(component1.group()).thenReturn("vendor1"); when(component1.name()).thenReturn("project1"); when(component1.version()).thenReturn("version1"); when(component2.group()).thenReturn("vendor2"); when(component2.name()).thenReturn("project2"); when(component2.version()).thenReturn("version2"); when(component3.group()).thenReturn("vendor1"); when(component3.name()).thenReturn("project1"); when(component3.version()).thenReturn("version2"); ComposerJsonProcessor underTest = new ComposerJsonProcessor(composerJsonExtractor); Content output = underTest.generatePackagesFromComponents(repository, asList(component1, component2, component3)); assertEquals(packagesJson, readStreamToString(output.openInputStream()), true); }