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

The following examples show how to use org.powermock.api.easymock.PowerMock#replayAll() . 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: QueryDataTest.java    From datawave with Apache License 2.0 6 votes vote down vote up
@Test
public void testCopyConstructor() {
    // Set expectations
    expect(this.copy.getQuery()).andReturn("TEST");
    expect(this.copy.getRanges()).andReturn(Arrays.asList(this.range));
    expect(this.copy.getSettings()).andReturn(Arrays.asList(this.setting));
    
    // Run the test
    PowerMock.replayAll();
    QueryData subject = new QueryData(this.copy);
    String result1 = subject.getQuery();
    Collection<Range> result2 = subject.getRanges();
    subject.addIterator(this.setting);
    Collection<IteratorSetting> result3 = subject.getSettings();
    String result4 = subject.toString();
    PowerMock.verifyAll();
    
    // Verify results
    assertNotNull("Query should not be null", result1);
    assertNotNull("Ranges should not be null", result2);
    assertTrue("Ranges should not be empty", !result2.isEmpty());
    assertNotNull("Settings should not be null", result3);
    assertTrue("Settings should not be empty", !result3.isEmpty());
    assertEquals("Settings should have a size of 2", 2, result3.size());
    assertNotNull("toString should not be null", result4);
}
 
Example 2
Source File: RegionFooterHeaderTest.java    From fastods with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void nonEmptyText() throws IOException {
    final StringBuilder sb = new StringBuilder();
    final Text text = PowerMock.createMock(Text.class);
    final PageSectionContent content = new RegionFooterHeader(null, text, null);
    PowerMock.resetAll();

    EasyMock.expect(text.isEmpty()).andReturn(false).times(3);
    text.appendXMLContent(this.util, sb);
    text.addEmbeddedStylesFromFooterHeader(this.stylesContainer);
    text.addEmbeddedStylesFromFooterHeader(this.stylesContainer);
    PowerMock.replayAll();

    content.appendXMLToMasterStyle(this.util, sb);
    Assert.assertEquals("<style:region-left></style:region-left>", sb.toString());
    content.addEmbeddedStyles(this.stylesContainer);
    content.addEmbeddedStyles(this.stylesContainer);
    PowerMock.verifyAll();
}
 
Example 3
Source File: HandlerTest.java    From lambadaframework with MIT License 6 votes vote down vote up
private Router getMockRouter(String methodName, Class<?>... parameterTypes) throws NoSuchMethodException {

        Invocable mockInvocable = PowerMock.createMock(Invocable.class);
        expect(mockInvocable.getHandlingMethod())
                .andReturn(DummyController.class.getDeclaredMethod(methodName, parameterTypes))
                .anyTimes();

        expect(mockInvocable.getHandler())
                .andReturn(MethodHandler.create(DummyController.class))
                .anyTimes();

        org.lambadaframework.jaxrs.model.ResourceMethod mockResourceMethod = PowerMock.createMock(org.lambadaframework.jaxrs.model.ResourceMethod
                .class);
        expect(mockResourceMethod.getInvocable())
                .andReturn(mockInvocable)
                .anyTimes();

        Router mockRouter = PowerMock.createMock(Router.class);
        expect(mockRouter.route(anyObject()))
                .andReturn(mockResourceMethod)
                .anyTimes();

        PowerMock.replayAll();
        return mockRouter;
    }
 
Example 4
Source File: TableCellWalkerTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testRemoveRowStyle() throws IOException {
    PowerMock.resetAll();
    this.initWalker(0);
    this.row.removeRowStyle();

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

    PowerMock.verifyAll();
}
 
Example 5
Source File: TableCellTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testMerge() throws IOException {
    PowerMock.resetAll();
    EasyMock.expect(TableColdCell.create(EasyMock.eq(this.xmlUtil))).andReturn(this.tcc)
            .anyTimes();
    this.table.setCellMerge(ROW_INDEX, COLUMN_INDEX, 7, 12);

    PowerMock.replayAll();
    this.cell.setStringValue("value");
    this.cell.setCellMerge(7, 12);

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

    PowerMock.replayAll();
    this.cellWalker = new TableCellWalker(this.table);
    this.cellWalker.to(10);
    this.cellWalker.setColumnsSpanned(8);

    PowerMock.verifyAll();
}
 
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 testRowsSpanned() throws IOException {
    PowerMock.resetAll();
    this.row.setRowsSpanned(10, 8);

    PowerMock.replayAll();
    this.cellWalker.to(10);
    this.cellWalker.setRowsSpanned(8);

    PowerMock.verifyAll();
}
 
Example 8
Source File: TestLegacyBaseQueryLogicTransformer.java    From datawave with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateResponse_ResultsPageComplete() throws Exception {
    // Set expectations
    expect(this.resultsPage.getResults()).andReturn(Arrays.asList(new Object()));
    expect(this.resultsPage.getStatus()).andReturn(ResultsPage.Status.COMPLETE);
    
    // Run the test
    PowerMock.replayAll();
    TestTransformer subject = new TestTransformer(new MarkingFunctions.Default(), this.response);
    BaseQueryResponse result1 = subject.createResponse(this.resultsPage);
    PowerMock.verifyAll();
    
    // Verify results
    assertSame("BaseQueryResponse should not be null", result1, this.response);
}
 
Example 9
Source File: TableCellTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testTextCovered() throws IOException {
    PowerMock.resetAll();
    EasyMock.expect(TableColdCell.create(EasyMock.eq(this.xmlUtil))).andReturn(this.tcc);

    PowerMock.replayAll();
    this.cell.setCovered();
    this.cell.setText(Text.content("text"));

    PowerMock.verifyAll();
    this.assertCellXMLEquals(
            "<table:covered-table-cell office:value-type=\"string\" office:string-value=\"\">" +
                    "<text:p>text</text:p>" + "</table:covered-table-cell>");
}
 
Example 10
Source File: TableCellTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testMarkRowsSpanned1() {
    PowerMock.resetAll();
    PowerMock.replayAll();
    this.cell.markColumnsSpanned(1);

    PowerMock.verifyAll();
}
 
Example 11
Source File: KafkaSourceConnectorTest.java    From MirrorTool-for-Kafka-Connect with Apache License 2.0 5 votes vote down vote up
@Test(expected = ConfigException.class)
public void testStartMissingBootstrapServers() {
  suppress(method(PartitionMonitor.class, "start"));
  PowerMock.replayAll();

  sourceProperties.remove(KafkaSourceConnectorConfig.SOURCE_BOOTSTRAP_SERVERS_CONFIG);
  connector.start(sourceProperties);

  PowerMock.verifyAll();
}
 
Example 12
Source File: OdsElementsTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testAddChildCellStyle() {
    PowerMock.resetAll();
    EasyMock.expect(this.contentElement
            .addChildCellStyle(TableCellStyle.DEFAULT_CELL_STYLE, CellType.STRING))
            .andReturn(null);

    PowerMock.replayAll();
    this.odsElements.addCellStyle(TableCellStyle.DEFAULT_CELL_STYLE, CellType.STRING);

    PowerMock.verifyAll();
}
 
Example 13
Source File: DownloadServletTest.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@Test
public void testDownloadProjectOutputFileWithoutTarget() throws IOException {
  MockHttpServletRequest request = new MockHttpServletRequest(DOWNLOAD_URL +
      "project-output/1234");
  expect(exporterMock.exportProjectOutputFile(USER_ID, PROJECT_ID, null))
      .andReturn(dummyApk);
  PowerMock.replayAll();
  DownloadServlet download = new DownloadServlet();
  MockHttpServletResponse response = new MockHttpServletResponse();
  download.doGet(request, response);
  checkResponseHeader(response, "attachment; filename=\"filename123.apk\"");
  assertEquals("application/vnd.android.package-archive",
      response.getContentType());
  PowerMock.verifyAll();
}
 
Example 14
Source File: TableColumnStyleTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testAddNewDefaultCellStyleToFile() {
    final TableCellStyle cellStyle = TableCellStyle.builder("ok").hidden().build();
    final TableColumnStyle tcs =
            TableColumnStyle.builder("test").build();
    final OdsElements odsElements = PowerMock.createMock(OdsElements.class);

    PowerMock.resetAll();
    EasyMock.expect(odsElements.addContentStyle(tcs)).andReturn(true);

    PowerMock.replayAll();
    tcs.addToElements(odsElements);

    PowerMock.verifyAll();
}
 
Example 15
Source File: UnsortedChildrenTesterTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testChildrenEquals() throws IOException, SAXException {
    PowerMock.resetAll();

    PowerMock.replayAll();
    final Node x = this.getNode("<x><r/></x>");
    final Node y = this.getNode("<y><s/><t/></y>");
    final Node z = this.getNode("<z><s/><u/></z>");
    final Node a = this.getNode("<a><u/><s/></a>");
    Assert.assertFalse(this.tester.childrenEquals(x, y));
    Assert.assertFalse(this.tester.childrenEquals(y, z));
    Assert.assertTrue(this.tester.childrenEquals(z, a));

    PowerMock.verifyAll();
}
 
Example 16
Source File: RowCellWalkerImplTest.java    From fastods with GNU General Public License v3.0 5 votes vote down vote up
@Test
public final void testSetTooltipLong() {
    PowerMock.resetAll();
    EasyMock.expect(this.row.getOrCreateCell(0)).andReturn(this.cell);
    this.cell.setTooltip("tt", SimpleLength.cm(3), SimpleLength.cm(4), true);

    PowerMock.replayAll();
    this.cellWalker.setTooltip("tt", SimpleLength.cm(3), SimpleLength.cm(4), true);

    PowerMock.verifyAll();
}
 
Example 17
Source File: ResultSetDataWrapperTest.java    From fastods with GNU General Public License v3.0 4 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public final void testWrapperWithColumnHints()
        throws IOException, FastOdsException {
    final Logger logger = PowerMock.createNiceMock(Logger.class);
    final MockResultSet rs = this.tester
            .createResultSet(Arrays.asList("number", "word", "code"),
                    Arrays.asList(Arrays.<Object>asList(0.13, "a", "13a")));
    final ResultSetDataWrapper wrapper =
            ResultSetDataWrapper.builder("range", rs).logger(this.logger).noAutoFilter()
                    .typeValue(0, CellType.PERCENTAGE).build();

    PowerMock.resetAll();
    EasyMock.expect(this.walker.rowIndex()).andReturn(0);
    EasyMock.expect(this.walker.colIndex()).andReturn(0);

    this.walker.setStringValue("number");
    this.walker.setStyle(EasyMock.isA(TableCellStyle.class));
    this.walker.next();
    this.walker.setStringValue("word");
    this.walker.setStyle(EasyMock.isA(TableCellStyle.class));
    this.walker.next();
    this.walker.setStringValue("code");
    this.walker.setStyle(EasyMock.isA(TableCellStyle.class));
    this.walker.next();
    this.walker.nextRow();
    this.walker.to(0);
    this.walker.setCellValue(PercentageValue.from(0.13));
    this.walker.next();
    this.walker.setCellValue(StringValue.from("a"));
    this.walker.next();
    this.walker.setCellValue(StringValue.from("13a"));
    this.walker.next();
    this.walker.nextRow();
    this.walker.to(0);
    this.walker.setStringValue("");
    this.walker.next();
    this.walker.setStringValue("");
    this.walker.next();
    this.walker.setStringValue("");
    this.walker.next();
    this.walker.nextRow();

    PowerMock.replayAll();
    wrapper.addToTable(this.walker);

    PowerMock.verifyAll();
}
 
Example 18
Source File: MongodbSourceTaskTest.java    From kafka-connect-mongodb with Apache License 2.0 4 votes vote down vote up
private void replay() {
    PowerMock.replayAll();
}
 
Example 19
Source File: FileStreamSourceTaskTest.java    From kafka-connector-skeleton with Apache License 2.0 4 votes vote down vote up
private void replay() {
    PowerMock.replayAll();
    verifyMocks = true;
}
 
Example 20
Source File: TableBuilderTest.java    From fastods with GNU General Public License v3.0 3 votes vote down vote up
@Test
public void testSetRowsSpanned1() throws IOException {
    PowerMock.resetAll();

    PowerMock.replayAll();
    this.builder.setRowsSpanned(this.table, this.appender, 2, 2, 1);

    PowerMock.verifyAll();

}