Search in sources :

Example 6 with RepoUsage

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);
}
Also used : Response(org.springframework.extensions.webscripts.TestWebScriptServer.Response) TestWebScriptServer(org.springframework.extensions.webscripts.TestWebScriptServer) JSONObject(org.json.JSONObject) RepoUsage(org.alfresco.service.cmr.admin.RepoUsage)

Aggregations

RepoUsage (org.alfresco.service.cmr.admin.RepoUsage)6 HashMap (java.util.HashMap)3 JSONObject (org.json.JSONObject)3 TestWebScriptServer (org.springframework.extensions.webscripts.TestWebScriptServer)3 Response (org.springframework.extensions.webscripts.TestWebScriptServer.Response)3 RepoUsageStatus (org.alfresco.service.cmr.admin.RepoUsageStatus)2 Date (java.util.Date)1 Map (java.util.Map)1 RunAsWork (org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork)1 LicenseDescriptor (org.alfresco.service.license.LicenseDescriptor)1