@Test
  public void getExistingUser() throws Exception {
    Authentication authentication = TestAuthenticationFactory.createAdministrator();
    SecurityContextHolder.getContext().setAuthentication(authentication);

    // create a new user viewUser
    Map<String, Object> requestProperties = new HashMap<>();
    requestProperties.put(UserResourceProvider.USER_USERNAME_PROPERTY_ID, "viewUser");
    requestProperties.put(UserResourceProvider.USER_PASSWORD_PROPERTY_ID, "password");
    requestProperties.put(UserResourceProvider.USER_ADMIN_PROPERTY_ID, false);
    requestProperties.put(UserResourceProvider.USER_ACTIVE_PROPERTY_ID, true);

    Request request = PropertyHelper.getCreateRequest(Collections.singleton(requestProperties), null);
    RequestStatus requestStatus = userResourceProvider.createResources(request);
    assertNotNull(requestStatus);

    // verify the created username
    Request getRequest = PropertyHelper.getReadRequest(new HashSet<>(Arrays.asList("Users")));
    Predicate predicate = new PredicateBuilder()
        .property(UserResourceProvider.USER_USERNAME_PROPERTY_ID).equals("viewuser").toPredicate();
    Set<Resource> resources = userResourceProvider.getResources(getRequest, predicate);
    assertEquals(resources.size(), 1);
    Resource resource = resources.iterator().next();

    String userName = resource.getPropertyValue(UserResourceProvider.USER_USERNAME_PROPERTY_ID).toString();
    assertEquals("viewuser", userName);

    // delete the created username
    requestStatus = userResourceProvider.deleteResources(request, predicate);
    assertNotNull(requestStatus);

    // verify that the username was deleted
    resources = userResourceProvider.getResources(getRequest, null);
    assertEquals(resources.size(), 0);
  }
Creates a user and retrieves the user using the same username but in lowercase. Verifies
that the retrieval is successful and that the retrieved username is the same as the one
that was used during creation.

@throws Exception
ambari-server/src/test/java/org/apache/ambari/server/controller/internal/UserResourceProviderDBTest.java