SymbolGroupDAO { public SymbolGroup get(User user, long projectId, Long groupId) throws NotFoundException { final Project project = projectRepository.findById(projectId).orElse(null); final SymbolGroup group = symbolGroupRepository.findById(groupId).orElse(null); checkAccess(user, project, group); loadLazyRelations(group); return group; } @Autowired  SymbolGroupDAO(ProjectRepository projectRepository, ProjectDAO projectDAO,
                          SymbolGroupRepository symbolGroupRepository, SymbolRepository symbolRepository,
                          @Lazy SymbolDAO symbolDAO, ObjectMapper objectMapper); List<SymbolGroup> importGroups(User user, Long projectId, SymbolGroupsImportableEntity importableEntity); List<SymbolGroup> importGroups(User user, Project project, List<SymbolGroup> groups, Map<String, SymbolImportConflictResolutionStrategy> conflictResolutions); void create(User user, SymbolGroup group); List<SymbolGroup> create(User user, Long projectId, List<SymbolGroup> groups); List<SymbolGroup> getAll(User user, long projectId); SymbolGroup get(User user, long projectId, Long groupId); void update(User user, SymbolGroup group); SymbolGroup move(User user, SymbolGroup group); void delete(User user, long projectId, Long groupId); void checkAccess(User user, Project project, SymbolGroup group);  }
@Test public void shouldGetAGroupByItsID() throws NotFoundException { User user = new User(); user.setId(USER_ID); Project project = new Project(); project.setId(PROJECT_ID); SymbolGroup group = new SymbolGroup(); group.setId(GROUP_ID); group.setProject(project); given(projectRepository.findById(PROJECT_ID)).willReturn(Optional.of(project)); given(symbolGroupRepository.findById(GROUP_ID)).willReturn(Optional.of(group)); SymbolGroup g = symbolGroupDAO.get(user, PROJECT_ID, group.getId()); assertThat(g, is(equalTo(group))); }
@Test(expected = NotFoundException.class) public void shouldThrowAnExceptionIfTheGroupCanNotBeFound() throws NotFoundException { User user = new User(); user.setId(USER_ID); symbolGroupDAO.get(user, -1L, -1L); }