@Test
public void test_searchByUPN() throws Exception {

    DirectoryUser directoryUser = new DirectoryUser();
    directoryUser.setDisplayName("testUser");
    directoryUser.setGivenName("testUser");
    directoryUser.setUserEmail("testUser@t-mobile.com");
    directoryUser.setUserId("testuser01");
    directoryUser.setUserName("testUser");
    List<DirectoryUser> persons = new ArrayList<>();
    persons.add(directoryUser);
    DirectoryObjects users = new DirectoryObjects();
    DirectoryObjectsList usersList = new DirectoryObjectsList();
    usersList.setValues(persons.toArray(new DirectoryUser[persons.size()]));
    users.setData(usersList);
    String responseMessage =new ObjectMapper().writeValueAsString(users);
    ResponseEntity<DirectoryObjects> responseEntityExpected = ResponseEntity.status(HttpStatus.OK).body(users);
    when(directoryService.searchByUPN(Mockito.any())).thenReturn(responseEntityExpected);
    mockMvc.perform(MockMvcRequestBuilders.get("/v2/ldap/users?UserPrincipalName=test_principal_name")
            .header("vault-token", "5PDrOhsy4ig8L3EpsJZSLAMg")
            .header("Content-Type", "application/json;charset=UTF-8"))
            .andExpect(status().isOk())
            .andExpect(content().string(containsString(responseMessage)));
}