@Test public void call() throws Exception { mockStatic(SwiftContext.class); when(SwiftContext.get()).thenReturn(mock(BeanFactory.class)); RealtimeService realtimeService = mock(RealtimeService.class); when(SwiftContext.get().getBean(RealtimeService.class)).thenReturn(realtimeService); SourceKey tableKey = mock(SourceKey.class); SwiftResultSet resultSet = mock(SwiftResultSet.class); RealtimeInsertJob job = new RealtimeInsertJob(tableKey, resultSet); assertTrue(job.call()); verify(realtimeService).insert(tableKey, resultSet); doThrow(new Exception()).when(realtimeService).insert(tableKey, resultSet); assertFalse(job.call()); }
@Override public Boolean call() { try { ReusableResultSet reusableResultSet = backup(); insert(reusableResultSet); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } }
RealtimeInsertJob extends BaseJob<Boolean, SwiftResultSet> { @Override public Boolean call() { try { ReusableResultSet reusableResultSet = backup(); insert(reusableResultSet); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } } }
RealtimeInsertJob extends BaseJob<Boolean, SwiftResultSet> { @Override public Boolean call() { try { ReusableResultSet reusableResultSet = backup(); insert(reusableResultSet); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } } RealtimeInsertJob(SourceKey tableKey, SwiftResultSet resultSet); }
RealtimeInsertJob extends BaseJob<Boolean, SwiftResultSet> { @Override public Boolean call() { try { ReusableResultSet reusableResultSet = backup(); insert(reusableResultSet); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } } RealtimeInsertJob(SourceKey tableKey, SwiftResultSet resultSet); @Override Boolean call(); }
RealtimeInsertJob extends BaseJob<Boolean, SwiftResultSet> { @Override public Boolean call() { try { ReusableResultSet reusableResultSet = backup(); insert(reusableResultSet); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } } RealtimeInsertJob(SourceKey tableKey, SwiftResultSet resultSet); @Override Boolean call();  }