BaseServiceImpl implements BaseService<ID, T> { @Override @Transactional public List<T> save(List<T> list) { for (T t : list) { validate(t); } return getDao().save(list); }  @Override long count(); @Override long count(Filter filter, boolean distinct); @Override T createNewEntity(); @Override @Transactional void delete(List<T> list); @Override @Transactional void delete(T t); @Override List<T> fetch(Filter filter, FetchJoinInformation... joins); @Override List<T> fetch(Filter filter, int pageNumber, int pageSize, FetchJoinInformation... joins); @Override List<T> fetch(Filter filter, int pageNumber, int pageSize, SortOrders sortOrders, FetchJoinInformation... joins); @Override List<T> fetch(Filter filter, SortOrders orders, FetchJoinInformation... joins); @Override T fetchById(ID id, FetchJoinInformation... joins); @Override List<T> fetchByIds(List<ID> ids, FetchJoinInformation... joins); @Override List<T> fetchByIds(List<ID> ids, SortOrders sortOrders, FetchJoinInformation... joins); @Override T fetchByUniqueProperty(String propertyName, Object value, boolean caseSensitive, FetchJoinInformation... joins); @Override List<T> find(Filter filter); @Override List<T> find(Filter filter, SortOrder... orders); @Override List<T> findAll(); @Override List<T> findAll(SortOrder... orders); @Override T findById(ID id); @Override T findByUniqueProperty(String propertyName, Object value, boolean caseSensitive); @Override List<S> findDistinct(Filter filter, String distinctField, Class<S> elementType, SortOrder... orders); @Override List<S> findDistinctInCollectionTable(String tableName, String distinctField, Class<S> elementType); @Override List<ID> findIds(Filter filter, Integer maxResults, SortOrder... orders); @Override List<ID> findIds(Filter filter, SortOrder... orders); @Override List<?> findSelect(Filter filter, String[] selectProperties, int pageNumber, int pageSize, SortOrders sortOrders); @Override List<?> findSelect(Filter filter, String[] selectProperties, SortOrders sortOrders); @Override Class<T> getEntityClass(); MessageService getMessageService(); @Override @Transactional List<T> save(List<T> list); @Override @Transactional T save(T t); @Override void validate(T t);  }
@Test public void testSave() { TestEntity obj = new TestEntity("name1", 14L); MockUtil.mockSave(dao, TestEntity.class); TestEntity result = service.save(obj); assertNotNull(result); verify(dao).save(obj); }
@Test public void testSaveList() { TestEntity obj1 = new TestEntity("name1", 14L); TestEntity obj2 = new TestEntity("name2", 15L); service.save(Lists.newArrayList(obj1, obj2)); verify(dao).save(Lists.newArrayList(obj1, obj2)); }