QuotaChecker { void checkGroupMembershipQuota(ObjectStoreConnection con, String domainName, String groupName, String caller) { if (!quotaCheckEnabled) { return; } final Quota quota = getDomainQuota(con, domainName); int objectCount = con.countGroupMembers(domainName, groupName) + 1; if (quota.getGroupMember() < objectCount) { throw ZMSUtils.quotaLimitError("group member quota exceeded - limit: " + quota.getGroupMember() + " actual: " + objectCount, caller); } } QuotaChecker(); Quota getDomainQuota(ObjectStoreConnection con, String domainName);  }
@Test public void testCheckGroupMembershipQuota() { QuotaChecker quotaCheck = new QuotaChecker(); Quota mockQuota = new Quota().setName("athenz") .setGroup(2).setGroupMember(2); ObjectStoreConnection con = Mockito.mock(ObjectStoreConnection.class); Mockito.when(con.getQuota("athenz")).thenReturn(mockQuota); Mockito.when(con.countGroupMembers("athenz", "readers")).thenReturn(1); quotaCheck.checkGroupMembershipQuota(con, "athenz", "readers", "caller"); }