### Question:
ComposerFormatAttributesExtractor extends ComponentSupport { public void extractFromZip(final TempBlob tempBlob, final NestedAttributesMap formatAttributes) throws IOException { Map<String, Object> contents = composerJsonExtractor.extractFromZip(tempBlob.getBlob()); if (!contents.isEmpty()) { extractStrings(contents, formatAttributes, STRINGS_MAPPING); extractAuthors(contents, formatAttributes); extractSupport(contents, formatAttributes); } } @Inject  ComposerFormatAttributesExtractor(final ComposerJsonExtractor composerJsonExtractor); void extractFromZip(final TempBlob tempBlob, final NestedAttributesMap formatAttributes);  }### Answer:
@Test public void extractInfoFromZipballWithJson() throws Exception { Map<String, Object> contents; try (InputStream in = getClass().getResourceAsStream("extractInfoFromZipballWithJson.composer.json")) { contents = new ObjectMapper().readValue(in, new TypeReference<Map<String, Object>>() { }); } when(tempBlob.getBlob()).thenReturn(blob); when(composerJsonExtractor.extractFromZip(blob)).thenReturn(contents); NestedAttributesMap attributesMap = new NestedAttributesMap("composer", new LinkedHashMap<>()); underTest.extractFromZip(tempBlob, attributesMap); assertThat(attributesMap.keys(), containsInAnyOrder(EXPECTED_FIELDS)); assertThat(attributesMap.get(P_NAME), is("vendor/project")); assertThat(attributesMap.get(P_VERSION), is("1.2.3")); assertThat(attributesMap.get(P_DESCRIPTION), is("Test description")); assertThat(attributesMap.get(P_TYPE), is("library")); assertThat((List<String>) attributesMap.get(P_KEYWORDS), containsInAnyOrder("keyword1", "keyword2", "keyword3")); assertThat(attributesMap.get(P_HOMEPAGE), is("http: assertThat(attributesMap.get(P_TIME), is("2008-05-15")); assertThat(attributesMap.get(P_LICENSE), is("MIT")); assertThat((List<String>) attributesMap.get(P_AUTHORS), containsInAnyOrder( "Author1 <author1@example.com> (http: "Author2 <author2@example.com> (http: assertThat(attributesMap.get(P_SUPPORT_EMAIL), is("email@example.com")); assertThat(attributesMap.get(P_SUPPORT_ISSUES), is("irc: assertThat(attributesMap.get(P_SUPPORT_FORUM), is("http: assertThat(attributesMap.get(P_SUPPORT_WIKI), is("http: assertThat(attributesMap.get(P_SUPPORT_SOURCE), is("http: assertThat(attributesMap.get(P_SUPPORT_DOCS), is("http: assertThat(attributesMap.get(P_SUPPORT_RSS), is("http: }
@Test public void extractInfoFromZipballWithoutJson() throws Exception { when(tempBlob.getBlob()).thenReturn(blob); when(composerJsonExtractor.extractFromZip(blob)).thenReturn(Collections.emptyMap()); NestedAttributesMap attributesMap = new NestedAttributesMap("composer", new LinkedHashMap<>()); underTest.extractFromZip(tempBlob, attributesMap); assertThat(attributesMap.keys(), is(empty())); }