PreprocessedRowsFlusher implements OdsAsyncFlusher { @Override public void flushInto(final XMLUtil xmlUtil, final ZipUTF8Writer writer) throws IOException { writer.append(this.cs); } PreprocessedRowsFlusher(final CharSequence cs); static PreprocessedRowsFlusher create(final XMLUtil xmlUtil,
                                                 final List<TableRowImpl> tableRows); @Override void flushInto(final XMLUtil xmlUtil, final ZipUTF8Writer writer); @Override boolean isEnd();  }
@Test public void flushIntoEmptyList() throws Exception { final List<TableRowImpl> rows = Collections.emptyList(); PowerMock.resetAll(); EasyMock.expect(this.w.append(this.sb)).andReturn(this.sb); PowerMock.replayAll(); final OdsAsyncFlusher flusher = new PreprocessedRowsFlusher(this.sb); flusher.flushInto(this.util, this.w); PowerMock.verifyAll(); }
@Test public void flushInto() throws Exception { final TableRowImpl r1 = PowerMock.createMock(TableRowImpl.class); final TableRowImpl r2 = PowerMock.createMock(TableRowImpl.class); final List<TableRowImpl> rows = Arrays.asList(r1, r2); PowerMock.resetAll(); r1.appendXMLToTable(EasyMock.eq(this.util), EasyMock.anyObject(StringBuilder.class)); r2.appendXMLToTable(EasyMock.eq(this.util), EasyMock.anyObject(StringBuilder.class)); EasyMock.expect(this.w.append(EasyMock.anyObject(StringBuilder.class))).andReturn(this.sb); PowerMock.replayAll(); final OdsAsyncFlusher flusher = PreprocessedRowsFlusher.create(this.util, rows); flusher.flushInto(this.util, this.w); PowerMock.verifyAll(); Assert.assertEquals("", this.sb.toString()); }