ExtSourceREMS extends ExtSourceSqlComplex implements ExtSourceApi { @Override public List<Map<String, String>> getUsersSubjects() { List<Map<String, String>> subjects = super.getUsersSubjects(); return filterNonExistingUsers(subjects); }  static PerunBlImpl setPerunBlImpl(PerunBlImpl perun); @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>> findSubjectsLogins(String searchString); @Override List<Map<String, String>> findSubjectsLogins(String searchString, int maxResults); @Override List<Map<String, String>> getGroupSubjects(Map<String, String> attributes); @Override List<Map<String, String>> getSubjectGroups(Map<String, String> attributes); @Override List<Map<String, String>> getUsersSubjects();  }
@Test public void getUsersSubjectsTest() throws Exception { System.out.println("getUsersSubjectsTest"); String usersQuery = "usersQuery"; Map<String, String> mapOfAttributes = new HashMap<>(); mapOfAttributes.put("usersQuery", usersQuery); mapOfAttributes.put("url", "some.url.com"); doReturn(mapOfAttributes).when(extSourceREMS).getAttributes(); doNothing().when(extSourceREMS).createConnection(); PreparedStatement preparedStatement = mock(PreparedStatement.class); doReturn(preparedStatement).when(extSourceREMS).getPreparedStatement(usersQuery, null, 0); ResultSet resultSet = mock(ResultSet.class, RETURNS_DEEP_STUBS); doReturn(resultSet).when(preparedStatement).executeQuery(); doReturn(true, false).when(resultSet).next(); doReturn("josef").when(resultSet).getString("firstName"); doReturn("xjosef").when(resultSet).getString("login"); User user = new User(); user.setFirstName("josef"); when(perunBl.getUsersManagerBl().getUsersByExtSourceTypeAndLogin(any(), anyString(), eq("xjosef"))).thenReturn(Collections.singletonList(user)); List<Map<String, String>> expectedSubjects = new ArrayList<>(); Map<String, String> subject = new HashMap<>(); subject.put("firstName", "josef"); subject.put("login", "xjosef"); subject.put("lastName", null); subject.put("titleBefore", null); subject.put("titleAfter", null); subject.put("middleName", null); expectedSubjects.add(subject); List<Map<String, String>> actualSubjects = extSourceREMS.getUsersSubjects(); assertEquals("subjects should be same", expectedSubjects, actualSubjects); }