ExtSourceXML extends ExtSource implements ExtSourceApi { @Override public List<Map<String, String>> getUsersSubjects() { String queryForUsers = getAttributes().get(UsersManager.USERS_QUERY); if(queryForUsers == null) throw new InternalErrorException("usersQuery can't be null"); prepareEnvironment(); return xpathParsing(queryForUsers, 0); }  static PerunBlImpl setPerunBlImpl(PerunBlImpl perun); @Override List<Map<String,String>> findSubjectsLogins(String searchString); @Override List<Map<String,String>> findSubjectsLogins(String searchString, int maxResulsts); @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); @JsonIgnore HttpURLConnection getCon(); @JsonIgnore void setCon(HttpURLConnection con);  }
@Test public void getUsersSubjectsTest() throws Exception { System.out.println("getUsersSubjectsTest"); File temp = File.createTempFile("temp",".xml"); temp.deleteOnExit(); Map<String, String> mapOfAttributes = new HashMap<>(); mapOfAttributes.put("usersQuery", "/Users/User[@id='42']"); mapOfAttributes.put("file", temp.getAbsolutePath()); mapOfAttributes.put("xmlMapping", "firstName=firstName,\nlogin=login"); doReturn(mapOfAttributes).when(extSourceXML).getAttributes(); try (BufferedWriter bw = new BufferedWriter(new FileWriter(temp))) { bw.write("<Users>\n<User id='42'>\n<firstName>arthur</firstName>\n<login>xdent</login>\n</User>\n</Users>"); } List<Map<String, String>> expectedSubjects = new ArrayList<>(); Map<String, String> mapOfSubject = new HashMap<>(); mapOfSubject.put("firstName", "arthur"); mapOfSubject.put("login", "xdent"); expectedSubjects.add(mapOfSubject); List<Map<String, String>> actualSubjects = extSourceXML.getUsersSubjects(); assertEquals("subjects should be same", expectedSubjects, actualSubjects); }