ScimServiceImpl implements ScimService { @Override public String findGroupIdByDisplayName(String groupDisplayName) { final SearchResultsWrapperWithId id = restTemplate.getForObject(groupsEndpoint + "?filter=displayName eq \"" + groupDisplayName + "\"&attributes=id", SearchResultsWrapperWithId.class); return extractId(id); } @Autowired  ScimServiceImpl(@Value("${c2s.patient-user.scim.url}") String uaaBaseUrl); @Override ScimUser save(ScimUser scimUser); @Override String findGroupIdByDisplayName(String groupDisplayName); @Override String findUserIdByUserName(String username); @Override @Transactional ScimGroupMember addUserToGroup(UserCreation userCreation, Scope scope, String groupId); @Override void addUserToGroups(UserCreation userCreation); @Override void updateUserWithNewGroup(UserCreation userCreation, Scope scope);  }
@Test public void testFindGroupIdByDisplayName() throws Exception { final String id = "id"; final String groupDisplayName = "groupDisplayName"; final SearchResultsWrapperWithId searchResultsMock = mock(SearchResultsWrapperWithId.class); final IdentifierDto identifier = new IdentifierDto(); identifier.setId(id); when(searchResultsMock.getResources()).thenReturn(Arrays.asList(identifier)); when(restTemplate.getForObject(groupsEndpoint + "?filter=displayName eq \"" + groupDisplayName + "\"&attributes=id", SearchResultsWrapperWithId.class)).thenReturn(searchResultsMock); final String response = sut.findGroupIdByDisplayName(groupDisplayName); assertEquals(id, response); }