GroupDatabaseService { public boolean validateTransferPermision(Long userId, Long dbId) throws SQLException { List<UserGroup> urGroups = userGroupDao.getUserGroupByUserId(userId); if (CollectionUtils.isNotEmpty(urGroups)) { for (UserGroup urGroup : urGroups) { List<DataBaseInfo> dataBaseInfos = dataBaseDao.getGroupDBsByGroup(urGroup.getGroup_id()); if (CollectionUtils.isNotEmpty(dataBaseInfos)) { return dataBaseInfos.stream().anyMatch(db -> db.getId().equals(dbId)); } } } return false; }  ValidatorChain validatePermision(LoginUser user, Errors errors); boolean isGroupHadDB(Long dbId, Long groupId); boolean isGroupHadDB(DataBaseInfo dataBaseModel); boolean validateTransferPermision(Long userId, Long dbId);  }
@Test public void validateTransferPermisionTest() throws SQLException { Assert.assertTrue(groupDatabaseService.validateTransferPermision(1L, 1L)); }