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

    List<String> userNames = Arrays.asList("user1", "uSer2", "User3", "useR4");
    List<String> lowercaseUserNames = new ArrayList<>();

    for (String username : userNames) {
      lowercaseUserNames.add(username.toLowerCase());
    }

    for (String userName : userNames) {
      Map<String, Object> requestProperties = new HashMap<>();
      requestProperties.put(UserResourceProvider.USER_USERNAME_PROPERTY_ID, userName);
      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(Collections.singleton(("Users")));
    Set<Resource> resources = userResourceProvider.getResources(getRequest, null);
    for (Resource resource : resources) {
      System.out.println("Resource: " + resource.getPropertyValue(UserResourceProvider.USER_USERNAME_PROPERTY_ID).toString());
    }
    for (String s: lowercaseUserNames) {
      System.out.println("LC UN: " + s);
    }
    assertEquals(lowercaseUserNames.size(), resources.size());
    for (Resource resource : resources) {
      String userName = resource.getPropertyValue(UserResourceProvider.USER_USERNAME_PROPERTY_ID).toString();
      assertTrue(lowercaseUserNames.contains(userName));
    }

    // delete the users
    for (String userName : userNames) {
      Predicate predicate = new PredicateBuilder()
          .property(UserResourceProvider.USER_USERNAME_PROPERTY_ID).equals(userName).toPredicate();
      RequestStatus requestStatus = userResourceProvider.deleteResources(null /* not used */, predicate);
      assertNotNull(requestStatus);
    }

    // verify that the username was deleted
    resources = userResourceProvider.getResources(getRequest, null);
    assertEquals(resources.size(), 0);
  }
Adds an array of users, retrieves the users and verifies that the usernames do not differ
from the ones that were used during creation.

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