Java Code Examples for org.powermock.api.easymock.PowerMock#resetAll()

The following examples show how to use org.powermock.api.easymock.PowerMock#resetAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextTest.java    From fastods with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testEmbeddedStyles() {
    final StylesContainer container = PowerMock.createMock(StylesContainerImpl.class);
    final TextStyle ts = TextStyle.builder("s").visible().fontWeightBold().build();
    final Text text =
            Text.builder().parStyledContent("ok", ts).parStyledContent("ok2", ts).build();

    PowerMock.resetAll();
    EasyMock.expect(container.addContentFontFaceContainerStyle(ts)).andReturn(true);
    EasyMock.expect(container.addContentFontFaceContainerStyle(ts)).andReturn(false);

    PowerMock.replayAll();
    text.addEmbeddedStylesFromCell(container);

    PowerMock.verifyAll();
}
 
Example 2
Source File: BeginTableFlusherTest.java    From fastods with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void test() throws IOException {
    final TableAppender appender = PowerMock.createMock(TableAppender.class);
    final OdsAsyncFlusher btf = new BeginTableFlusher(appender);
    final XMLUtil xmlUtil = XMLUtil.create();
    final ZipUTF8Writer writer = PowerMock.createMock(ZipUTF8Writer.class);

    PowerMock.resetAll();
    appender.appendPreambleOnce(xmlUtil, writer);

    PowerMock.replayAll();
    final boolean end = btf.isEnd();
    btf.flushInto(xmlUtil, writer);

    PowerMock.verifyAll();
    Assert.assertFalse(end);
}
 
Example 3
Source File: TableCellTest.java    From fastods with GNU General Public License v3.0 6 votes vote down vote up
@Test
public final void testBooleanFalse() throws IOException {
    final TableCellStyle cs = PowerMock.createMock(TableCellStyle.class);
    final DataStyle booleanDataStyle = this.ds.getBooleanDataStyle();

    PowerMock.resetAll();
    this.playAddStyle(cs, booleanDataStyle);

    PowerMock.replayAll();
    this.cell.setBooleanValue(false);

    PowerMock.verifyAll();
    this.assertCellXMLEquals(
            "<table:table-cell table:style-name=\"name\" office:value-type=\"boolean\" " +
                    "office:boolean-value=\"false\"/>");
}
 
Example 4
Source File: TableCellTest.java    From fastods with GNU General Public License v3.0 6 votes vote down vote up
@Test
public final void testSetMatrixSpanned() throws IOException {
    final TableColdCell cold = PowerMock.createMock(TableColdCell.class);

    PowerMock.resetAll();
    EasyMock.expect(TableColdCell.create(this.xmlUtil)).andReturn(cold);
    cold.setFormula("f");
    cold.setMatrixRowsSpanned(2);
    cold.setMatrixColumnsSpanned(3);
    EasyMock.expect(cold.isCovered()).andReturn(true);
    cold.appendXMLToTable(EasyMock.eq(this.xmlUtil), EasyMock.isA(Appendable.class));

    PowerMock.replayAll();
    this.cell.setMatrixFormula("f", 2, 3);
    final String cellXML = this.getCellXML();

    PowerMock.verifyAll();
    Assert.assertEquals("<table:covered-table-cell", cellXML);
}
 
Example 5
Source File: TableCellTest.java    From fastods with GNU General Public License v3.0 6 votes vote down vote up
@Test
public final void testSetMatrix() throws IOException {
    final TableColdCell cold = PowerMock.createMock(TableColdCell.class);

    PowerMock.resetAll();
    EasyMock.expect(TableColdCell.create(this.xmlUtil)).andReturn(cold);
    cold.setFormula("f");
    cold.setMatrixRowsSpanned(1);
    cold.setMatrixColumnsSpanned(1);
    EasyMock.expect(cold.isCovered()).andReturn(false);
    cold.appendXMLToTable(EasyMock.eq(this.xmlUtil), EasyMock.isA(Appendable.class));

    PowerMock.replayAll();
    this.cell.setMatrixFormula("f");
    final String cellXML = this.getCellXML();

    PowerMock.verifyAll();
    Assert.assertEquals("<table:table-cell", cellXML);
}
 
Example 6
Source File: ContentElementTest.java    From fastods with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testWrite() throws IOException {
    final ZipUTF8WriterMockHandler handler = ZipUTF8WriterMockHandler.create();
    final ZipUTF8Writer writer = handler.getInstance(ZipUTF8Writer.class);

    PowerMock.resetAll();
    this.container
            .writeFontFaceDecls(EasyMock.eq(this.xmlUtil), EasyMock.isA(Appendable.class));
    this.container
            .writeHiddenDataStyles(EasyMock.eq(this.xmlUtil), EasyMock.isA(Appendable.class));
    this.container.writeContentAutomaticStyles(EasyMock.eq(this.xmlUtil),
            EasyMock.isA(Appendable.class));

    PowerMock.replayAll();
    final Table t = this.createTable("t", 100, 100);
    this.content.addTable(t);
    this.content.write(this.xmlUtil, writer);

    DomTester.assertEquals(PREAMBLE_BODY +
                    "<office:spreadsheet>" +
                    "<table:table table:name=\"t\" table:style-name=\"ta1\" table:print=\"false\"><office:forms form:automatic-focus=\"false\" form:apply-design-mode=\"false\"/><table:table-column table:style-name=\"co1\" table:number-columns-repeated=\"1024\" table:default-cell-style-name=\"Default\"/></table:table>" +
                    "</office:spreadsheet>" +
                    POSTAMBLE_BODY,
            this.getString(handler));
}
 
Example 7
Source File: RowCellWalkerImplTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testObject() {
    final CellValue value = this.converter.from(null);

    PowerMock.resetAll();
    expect(this.row.getOrCreateCell(10)).andReturn(this.cell);
    this.cell.setCellValue(value);

    PowerMock.replayAll();
    this.cellWalker.to(10);
    this.cellWalker.setCellValue(value);

    PowerMock.verifyAll();
}
 
Example 8
Source File: TableAppenderTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void appendShapesTest() throws IOException {
    final DrawFrame drawFrame =
            DrawFrame.builder("a", new DrawImage("href"), SVGRectangle.cm(0, 1, 2, 3)).build();

    PowerMock.resetAll();
    EasyMock.expect(this.tb.getName()).andReturn("table1");
    EasyMock.expect(this.tb.getStyleName()).andReturn("table-style1");
    EasyMock.expect(this.tb.getCustomValueByAttribute()).andReturn(null);
    EasyMock.expect(this.tb.getColumns())
            .andReturn(FastFullList.<TableColumnImpl>newListWithCapacity(1));
    EasyMock.expect(this.tb.getShapes()).andReturn(Arrays.<Shape>asList(drawFrame));

    PowerMock.replayAll();
    this.assertPreambleXMLEquals(
            "<table:table table:name=\"table1\" table:style-name=\"table-style1\" " +
                    "table:print=\"false\">" + "<office:forms form:automatic-focus=\"false\" " +
                    "form:apply-design-mode=\"false\"/>" +
                    "<table:table-column table:style-name=\"co1\" " +
                    "table:number-columns-repeated=\"1024\" " +
                    "table:default-cell-style-name=\"Default\"/>" +
                    "<table:shapes><draw:frame draw:name=\"a\" " +
                    "draw:z-index=\"0\" svg:width=\"2cm\" svg:height=\"3cm\" svg:x=\"0cm\" " +
                    "svg:y=\"1cm\"><draw:image xlink:href=\"href\" xlink:type=\"simple\" " +
                    "xlink:show=\"embed\" xlink:actuate=\"onLoad\"/>" +
                    "</draw:frame></table:shapes>");

    PowerMock.verifyAll();
}
 
Example 9
Source File: TableCellWalkerTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testMarkColumnsSpanned() throws IOException {
    PowerMock.resetAll();
    this.initWalker(0);
    this.cell.markColumnsSpanned(5);

    PowerMock.replayAll();
    this.cellWalker = new TableCellWalker(this.table);
    this.cellWalker.markColumnsSpanned(5);

    PowerMock.verifyAll();
}
 
Example 10
Source File: RegionPageSectionTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testEmbeddedNullMode() {
    final StylesContainer sc = PowerMock.createMock(StylesContainerImpl.class);
    final PageSection headerSection = PageSection.regionBuilder().build();

    PowerMock.resetAll();
    PowerMock.replayAll();
    headerSection.addEmbeddedStyles(sc);

    PowerMock.verifyAll();
}
 
Example 11
Source File: DateValueTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testSetConstructor() {
    PowerMock.resetAll();
    final TableCell cell = PowerMock.createMock(TableCell.class);
    cell.setDateValue(new Date(10));

    PowerMock.replayAll();
    final Date date = new Date(10);
    final CellValue dv = new DateValue(date);
    date.setTime(0);
    dv.setToCell(cell);

    PowerMock.verifyAll();
}
 
Example 12
Source File: TableHelperTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testSetCellMerge() throws IOException, ParseException {
    PowerMock.resetAll();
    this.table.setCellMerge(6, 2, 9, 3);

    PowerMock.replayAll();
    this.tableHelper.setCellMerge(this.table, "C7", 9, 3);

    PowerMock.verifyAll();
}
 
Example 13
Source File: RowCellWalkerImplTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testFloat() {
    PowerMock.resetAll();
    expect(this.row.getOrCreateCell(10)).andReturn(this.cell);
    this.cell.setFloatValue(9.999f);

    PowerMock.replayAll();
    this.cellWalker.to(10);
    this.cellWalker.setFloatValue(9.999f);

    PowerMock.verifyAll();
}
 
Example 14
Source File: SQLToCellValueConverterTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testFromHintSQLXML() throws FastOdsException {
    PowerMock.resetAll();
    PowerMock.replayAll();
    Assert.assertEquals(new StringValue(XML_FASTODS),
            this.converter.from(CellType.STRING, new MockSQLXML(XML_FASTODS_RAW)));

    PowerMock.verifyAll();
}
 
Example 15
Source File: NamedOdsDocumentTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testSaveTo() throws IOException {
    PowerMock.resetAll();
    TestHelper.initMockDocument(this.odsElements);
    this.odsElements.saveAsync();

    PowerMock.replayAll();
    final NamedOdsDocument d = this.getDocument();
    d.save();

    PowerMock.verifyAll();
}
 
Example 16
Source File: TableCellWalkerTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testPercentageInt() throws IOException {
    PowerMock.resetAll();
    this.to(0, 10);
    this.cell.setPercentageValue(98);

    PowerMock.replayAll();
    this.cellWalker = new TableCellWalker(this.table);
    this.cellWalker.to(10);
    this.cellWalker.setPercentageValue(98);

    PowerMock.verifyAll();
}
 
Example 17
Source File: RowCellWalkerImplTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testInt() {
    PowerMock.resetAll();
    expect(this.row.getOrCreateCell(10)).andReturn(this.cell);
    this.cell.setFloatValue(999);

    PowerMock.replayAll();
    this.cellWalker.to(10);
    this.cellWalker.setFloatValue(999);

    PowerMock.verifyAll();
}
 
Example 18
Source File: SQLToCellValueConverterTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testFromTime() {
    PowerMock.resetAll();
    PowerMock.replayAll();
    Assert.assertEquals(new DateValue(UTIL_DATE), this.converter.from(SQL_TIME));

    PowerMock.verifyAll();
}
 
Example 19
Source File: TableAppenderTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void appendFourElementsPreambleTest() throws IOException {
    final TableColumnImpl x = this.newTC("x");

    PowerMock.resetAll();
    EasyMock.expect(this.tb.getName()).andReturn("table1");
    EasyMock.expect(this.tb.getStyleName()).andReturn("table-style1");
    EasyMock.expect(this.tb.getCustomValueByAttribute()).andReturn(null);
    EasyMock.expect(this.tb.getColumns())
            .andReturn(FastFullList.newList(x, x, this.newTC("y"), x));
    EasyMock.expect(this.tb.getShapes()).andReturn(Collections.<Shape>emptyList());

    PowerMock.replayAll();
    this.assertPreambleXMLEquals(
            "<table:table table:name=\"table1\" table:style-name=\"table-style1\" " +
                    "table:print=\"false\">" + "<office:forms form:automatic-focus=\"false\" " +
                    "form:apply-design-mode=\"false\"/>" +
                    "<table:table-column table:style-name=\"x\" " +
                    "table:number-columns-repeated=\"2\" " +
                    "table:default-cell-style-name=\"Default\"/>" +
                    "<table:table-column table:style-name=\"y\" " +
                    "table:default-cell-style-name=\"Default\"/>" + "<table:table-column " +
                    "table:style-name=\"x\"" + " " +
                    "table:default-cell-style-name=\"Default\"/>" + "<table:table-column " +
                    "table:style-name=\"co1\"" + " " +
                    "table:number-columns-repeated=\"1020\" " +
                    "table:default-cell-style-name=\"Default\"/>");
    PowerMock.verifyAll();
}
 
Example 20
Source File: RowCellWalkerImplTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testCellMerge() throws IOException {
    PowerMock.resetAll();
    this.row.setCellMerge(10, 5, 6);

    PowerMock.replayAll();
    this.cellWalker.to(10);
    this.cellWalker.setCellMerge(5, 6);

    PowerMock.verifyAll();
}