RdfEngine implements Engine { @Override public Set<Group> getGroups() { Set<Group> groups = new HashSet<>(); try (RepositoryConnection conn = repository.getConnection()) { GraphQuery query = conn.prepareGraphQuery(GET_GROUPS_QUERY); Model groupsModel = QueryResults.asModel(query.evaluate(), mf); groups.addAll(groupFactory.getAllExisting(groupsModel)); } return groups; }  @Override Optional<Role> getRole(String roleName); @Override Set<User> getUsers(); @Override User createUser(UserConfig userConfig); @Override void storeUser(User user); @Override boolean userExists(String username); @Override boolean userExists(Resource userId); @Override Optional<User> retrieveUser(String username); @Override void updateUser(User newUser); @Override void deleteUser(String username); @Override Set<Group> getGroups(); @Override Group createGroup(GroupConfig groupConfig); @Override void storeGroup(Group group); @Override boolean groupExists(String groupTitle); @Override boolean groupExists(Resource groupId); @Override Optional<Group> retrieveGroup(String groupTitle); @Override void updateGroup(Group newGroup); @Override void deleteGroup(String groupTitle); @Override Set<Role> getUserRoles(String username); @Override boolean checkPassword(String username, String password); @Override String getEngineName(); static final String ENGINE_NAME; }
@Test public void testGetGroups() { Set<String> expectedGroups = Stream.of(groupId1, groupId2).collect(Collectors.toSet()); Set<Group> groups = engine.getGroups(); assertEquals(expectedGroups.size(), groups.size()); groups.forEach(group -> assertTrue(expectedGroups.contains(group.getResource().stringValue()))); }