/** * userProfile == null for first time and not null for second time tnContext same situation as * userProfile * * @throws Exception */ public void testReport() throws Exception { // prepare and replay EasyMock.expect(request.getMisLogEvents()).andReturn(misLogEvents); EasyMock.expect(request.getServerTime()).andReturn(new Long(123)).times(2); EasyMock.expect(request.getUserProfile()).andReturn(null); EasyMock.expect(request.getUserProfile()).andReturn(UnittestUtil.createUserProfile()); EasyMock.expect(request.getTnContext()).andReturn(null); EasyMock.expect(request.getTnContext()).andReturn(UnittestUtil.createTnContext()); PowerMock.expectPrivate( misReportor, "addBusinessSpecificData", misLogEvents.get(0), new StringBuilder()); PowerMock.expectPrivate( misReportor, "addBusinessSpecificData", misLogEvents.get(1), new StringBuilder()); PowerMock.replayAll(); // invoke and verify misReportor.report(request); PowerMock.verifyAll(); // assert }
public void testReport_noFor() { // prepare and replay EasyMock.expect(request.getMisLogEvents()).andReturn(new ArrayList()); PowerMock.replayAll(); // invoke and verify misReportor.report(request); PowerMock.verifyAll(); // assert // no exception is ok }