TxcExportUtility { protected void writeDeckToZipStream(Deck deck, String exportedDeckName, ZipOutputStream zipOutputStream) throws ExportException { try { JSONObject deckAsJSON = deck.toJSON(exportedDeckName); zipOutputStream.putNextEntry(new ZipEntry(SPEC_FILENAME)); zipOutputStream.write(deckAsJSON.toString().getBytes()); zipOutputStream.closeEntry(); } catch (IOException | JSONException e) { throw new ExportException(ExportException.ExportProblem.WRITE_ERROR, e); } } TxcExportUtility(InputStreamBuilder inputStreamBuilder); void exportDeck(Deck deck, String exportedDeckName, File file);  }
@Test public void shouldAddDeckJSONToZipStream() throws Exception { JSONObject deckJSON = mock(JSONObject.class); when(deckJSON.toString()).thenReturn("JSON representation of a deck"); Deck deck = mock(Deck.class); when(deck.toJSON(any(String.class))).thenReturn(deckJSON); txcExportUtility.writeDeckToZipStream(deck, "Export Name", zipOutputStream); ArgumentCaptor<ZipEntry> zipEntryCaptor = ArgumentCaptor.forClass(ZipEntry.class); verify(zipOutputStream).putNextEntry(zipEntryCaptor.capture()); assertEquals(TxcExportUtility.SPEC_FILENAME, zipEntryCaptor.getValue().getName()); verify(zipOutputStream).write(deckJSON.toString().getBytes()); verify(zipOutputStream).closeEntry(); }