@Test public void testWrite() { final List<Group> groups = new ArrayList<>(); groups.add(new Group(Identifier.<Group>id(1L), "testGroup")); historyService.createHistory("any", groups, "Testing...", EventType.USER_ACTION_INFO, "user"); verify(mockHistoryCrudService).createHistory(eq("any"), any(Group.class), eq("Testing..."), eq(EventType.USER_ACTION_INFO), eq("user")); }
@Override @Transactional(propagation = Propagation.REQUIRES_NEW) public List<JpaHistory> createHistory(final String serverName, final List<Group> groups, final String event, final EventType eventType, final String user) { final List<JpaHistory> jpaHistoryList = new ArrayList<>(); if (groups != null) { for (Group group : groups) { jpaHistoryList.add(historyCrudService.createHistory(serverName, group, event, eventType, user)); } } return jpaHistoryList; }
HistoryServiceImpl implements HistoryService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public List<JpaHistory> createHistory(final String serverName, final List<Group> groups, final String event, final EventType eventType, final String user) { final List<JpaHistory> jpaHistoryList = new ArrayList<>(); if (groups != null) { for (Group group : groups) { jpaHistoryList.add(historyCrudService.createHistory(serverName, group, event, eventType, user)); } } return jpaHistoryList; } }
HistoryServiceImpl implements HistoryService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public List<JpaHistory> createHistory(final String serverName, final List<Group> groups, final String event, final EventType eventType, final String user) { final List<JpaHistory> jpaHistoryList = new ArrayList<>(); if (groups != null) { for (Group group : groups) { jpaHistoryList.add(historyCrudService.createHistory(serverName, group, event, eventType, user)); } } return jpaHistoryList; } @Autowired  HistoryServiceImpl(final HistoryCrudService historyCrudService); }
HistoryServiceImpl implements HistoryService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public List<JpaHistory> createHistory(final String serverName, final List<Group> groups, final String event, final EventType eventType, final String user) { final List<JpaHistory> jpaHistoryList = new ArrayList<>(); if (groups != null) { for (Group group : groups) { jpaHistoryList.add(historyCrudService.createHistory(serverName, group, event, eventType, user)); } } return jpaHistoryList; } @Autowired  HistoryServiceImpl(final HistoryCrudService historyCrudService); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) // Write history independent of any transaction. List<JpaHistory> createHistory(final String serverName, final List<Group> groups, final String event,
                                          final EventType eventType, final String user); @Override @Transactional(readOnly = true) List<JpaHistory> findHistory(final String groupName, final String serverName, final Integer numOfRec); }
HistoryServiceImpl implements HistoryService { @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public List<JpaHistory> createHistory(final String serverName, final List<Group> groups, final String event, final EventType eventType, final String user) { final List<JpaHistory> jpaHistoryList = new ArrayList<>(); if (groups != null) { for (Group group : groups) { jpaHistoryList.add(historyCrudService.createHistory(serverName, group, event, eventType, user)); } } return jpaHistoryList; } @Autowired  HistoryServiceImpl(final HistoryCrudService historyCrudService); @Override @Transactional(propagation = Propagation.REQUIRES_NEW) // Write history independent of any transaction. List<JpaHistory> createHistory(final String serverName, final List<Group> groups, final String event,
                                          final EventType eventType, final String user); @Override @Transactional(readOnly = true) List<JpaHistory> findHistory(final String groupName, final String serverName, final Integer numOfRec);  }