use of org.alfresco.service.cmr.admin.RepoUsage in project alfresco-remote-api by Alfresco.
the class AdminWebScriptTest method testUpdateUsage.
public void testUpdateUsage() throws Exception {
repoAdminService.updateUsage(UsageType.USAGE_ALL);
RepoUsage usage = repoAdminService.getUsage();
String url = "/api/admin/usage";
TestWebScriptServer.PostRequest req = new TestWebScriptServer.PostRequest(url, "", MimetypeMap.MIMETYPE_JSON);
Response response = sendRequest(req, Status.STATUS_OK, admin);
System.out.println(response.getContentAsString());
JSONObject json = new JSONObject(response.getContentAsString());
Long users = json.isNull(AbstractAdminWebScript.JSON_KEY_USERS) ? null : json.getLong(AbstractAdminWebScript.JSON_KEY_USERS);
assertEquals("Mismatched users", usage.getUsers(), users);
Long documents = json.isNull(AbstractAdminWebScript.JSON_KEY_DOCUMENTS) ? null : json.getLong(AbstractAdminWebScript.JSON_KEY_DOCUMENTS);
assertEquals("Mismatched documents", usage.getDocuments(), documents);
String licenseMode = json.isNull(AbstractAdminWebScript.JSON_KEY_LICENSE_MODE) ? null : json.getString(AbstractAdminWebScript.JSON_KEY_LICENSE_MODE);
assertEquals("Mismatched licenseMode", usage.getLicenseMode().toString(), licenseMode);
boolean readOnly = json.getBoolean(AbstractAdminWebScript.JSON_KEY_READ_ONLY);
assertEquals("Mismatched readOnly", usage.isReadOnly(), readOnly);
boolean updated = json.getBoolean(AbstractAdminWebScript.JSON_KEY_UPDATED);
assertEquals("Mismatched updated", true, updated);
}
Aggregations