@Test public void call() throws Exception { DeleteService deleteService = mock(DeleteService.class); when(SwiftContext.get().getBean(DeleteService.class)).thenReturn(deleteService); Where where = mock(Where.class); SourceKey tableKey = mock(SourceKey.class); DeleteJob job = new DeleteJob(tableKey, where); assertTrue(job.call()); verify(deleteService).delete(tableKey, where); doThrow(Exception.class).when(deleteService).delete(ArgumentMatchers.<SourceKey>any(), ArgumentMatchers.<Where>any()); assertFalse(job.call()); }
@Override public Boolean call() { try { SwiftContext.get().getBean(DeleteService.class).delete(sourceKey, where); SwiftLoggers.getLogger().info("Delete from table [{}] with [{}] success!", sourceKey.getId(), JsonBuilder.writeJsonString(where.getFilterBean())); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } }
DeleteJob extends BaseJob<Boolean, FilterBean> { @Override public Boolean call() { try { SwiftContext.get().getBean(DeleteService.class).delete(sourceKey, where); SwiftLoggers.getLogger().info("Delete from table [{}] with [{}] success!", sourceKey.getId(), JsonBuilder.writeJsonString(where.getFilterBean())); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } } }
DeleteJob extends BaseJob<Boolean, FilterBean> { @Override public Boolean call() { try { SwiftContext.get().getBean(DeleteService.class).delete(sourceKey, where); SwiftLoggers.getLogger().info("Delete from table [{}] with [{}] success!", sourceKey.getId(), JsonBuilder.writeJsonString(where.getFilterBean())); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } } DeleteJob(SourceKey sourceKey, Where where); }
DeleteJob extends BaseJob<Boolean, FilterBean> { @Override public Boolean call() { try { SwiftContext.get().getBean(DeleteService.class).delete(sourceKey, where); SwiftLoggers.getLogger().info("Delete from table [{}] with [{}] success!", sourceKey.getId(), JsonBuilder.writeJsonString(where.getFilterBean())); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } } DeleteJob(SourceKey sourceKey, Where where); @Override Boolean call(); @Override FilterBean serializedTag(); }
DeleteJob extends BaseJob<Boolean, FilterBean> { @Override public Boolean call() { try { SwiftContext.get().getBean(DeleteService.class).delete(sourceKey, where); SwiftLoggers.getLogger().info("Delete from table [{}] with [{}] success!", sourceKey.getId(), JsonBuilder.writeJsonString(where.getFilterBean())); return true; } catch (Exception e) { SwiftLoggers.getLogger().error(e); return false; } } DeleteJob(SourceKey sourceKey, Where where); @Override Boolean call(); @Override FilterBean serializedTag();  }