ExtSourceUnity extends ExtSource implements ExtSourceApi { @Override public List<Map<String, String>> getUsersSubjects() { String query = getAttributes().get(UsersManager.USERS_QUERY); prepareEnvironment(); return jsonParsing(query, 0); }  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(extSourceUnity).createConnection("uriAll"); String input = "{\"members\":[1]}"; InputStream is = new ByteArrayInputStream(input.getBytes()); doReturn(is).when(http).getInputStream(); HttpURLConnection http2 = mock(HttpURLConnection.class); doReturn(http2).when(extSourceUnity).createConnection("uriEntity/1/"); String input2 = "{\"id\":1,\"name\":miles,\"state\":valid,\"identities\":[{\"typeId\":identifier,\"translationProfile\":profile,\"value\":xmorales}]}"; InputStream is2 = new ByteArrayInputStream(input2.getBytes()); doReturn(is2).when(http2).getInputStream(); HttpURLConnection http3 = mock(HttpURLConnection.class); doReturn(http3).when(extSourceUnity).createConnection("uriEntity/1/attributes"); String input3 = "[{\"name\":name,\"values\":[miles morales]}]"; InputStream is3 = new ByteArrayInputStream(input3.getBytes()); doReturn(is3).when(http3).getInputStream(); Map<String, String> mapOfAttributes = new HashMap<>(); mapOfAttributes.put("usersQuery", "login=xmorales"); mapOfAttributes.put("uriAll", "uriAll"); mapOfAttributes.put("uriEntity", "uriEntity"); mapOfAttributes.put("unityMapping", "login={login},\nfirstName={firstName}"); doReturn(mapOfAttributes).when(extSourceUnity).getAttributes(); List<Map<String, String>> expectedSubjects = new ArrayList<>(); Map<String, String> subject = new HashMap<>(); subject.put("login", "xmorales"); expectedSubjects.add(subject); List<Map<String, String>> actualSubjects = extSourceUnity.getUsersSubjects(); assertEquals("subjects should be same", expectedSubjects, actualSubjects); }