ExtSourceVOOT extends ExtSource implements ExtSourceApi { @Override public List<Map<String, String>> getUsersSubjects() { query = getAttributes().get(UsersManager.USERS_QUERY); prepareEnvironment(); try { return getUsersFromRemote(getGroupsFromRemote(), 0); } catch (IOException ex) { log.error("IOException in getUsersSubjects() method while obtaining users" + "from VOOT external source", ex); } return null; }  static PerunBlImpl setPerunBlImpl(PerunBlImpl perun); @Override List<Map<String, String>> findSubjectsLogins(String searchString); @Override List<Map<String, String>> findSubjectsLogins(String searchString, int maxResults); @Override List<Map<String, String>> findSubjects(String searchString); @Override List<Map<String, String>> findSubjects(String searchString, int maxResults); @Override Map<String, String> getSubjectByLogin(String login); @Override List<Map<String, String>> getGroupSubjects(Map<String, String> attributes); @Override List<Map<String, String>> getUsersSubjects(); @Override void close(); @Override List<Map<String, String>> getSubjectGroups(Map<String, String> attributes);  }
@Test public void getUsersSubjectsTest() throws Exception { System.out.println("getUsersSubjectsTest"); HttpURLConnection http = mock(HttpURLConnection.class); doReturn(http).when(extSourceVOOT).createConnection("uriMembership"); String input = "{\"entry\":[{\"id\":\"1\"}]}"; InputStream is = new ByteArrayInputStream(input.getBytes()); doReturn(is).when(http).getInputStream(); HttpURLConnection http2 = mock(HttpURLConnection.class); doReturn(http2).when(extSourceVOOT).createConnection("uriMembers/1"); String input2 = "{\"entry\":[{\"id\":\"xmorales@1\",\"login\":xmorales@miles.sp,\"emails\":[{\"value\":miles@morales.sp}]}]}"; InputStream is2 = new ByteArrayInputStream(input2.getBytes()); doReturn(is2).when(http2).getInputStream(); Map<String, String> mapOfAttributes = new HashMap<>(); mapOfAttributes.put("usersQuery", "id=xmorales@1"); mapOfAttributes.put("uriMembership", "uriMembership"); mapOfAttributes.put("uriMembers", "uriMembers"); mapOfAttributes.put("vootMapping", "login={login},\nemail={email}"); doReturn(mapOfAttributes).when(extSourceVOOT).getAttributes(); List<Map<String, String>> expectedSubjects = new ArrayList<>(); Map<String, String> subject = new HashMap<>(); subject.put("login", "xmorales"); subject.put("email", "miles@morales.sp"); expectedSubjects.add(subject); List<Map<String, String>> actualSubjects = extSourceVOOT.getUsersSubjects(); assertEquals("subjects should be same", expectedSubjects, actualSubjects); }