use of org.alfresco.rest.api.model.DiscoveryDetails in project alfresco-remote-api by Alfresco.
the class DiscoveryApiTest method testGetDiscovery.
/**
* Tests get discovery.
* <p>GET:</p>
* {@literal <host>:<port>/alfresco/api/discovery}
*/
@Test
public void testGetDiscovery() throws Exception {
setRequestContext(null, user1, "wrongPassword");
get("discovery", null, 401);
setRequestContext(null, user1, null);
HttpResponse response = get("discovery", null, 200);
DiscoveryDetails discoveryDetails = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), DiscoveryDetails.class);
assertNotNull(discoveryDetails);
RepositoryInfo repositoryInfo = discoveryDetails.getRepository();
assertNotNull(repositoryInfo);
assertEquals("repoId", repositoryInfo.getId());
assertEquals("Enterprise", repositoryInfo.getEdition());
// Check version info
VersionInfo versionInfo = repositoryInfo.getVersion();
assertNotNull(versionInfo);
assertEquals("5", versionInfo.getMajor());
assertEquals("2", versionInfo.getMinor());
assertEquals("1", versionInfo.getPatch());
assertEquals("3", versionInfo.getHotfix());
assertEquals("r123456-b0", versionInfo.getLabel());
assertEquals(10051, versionInfo.getSchema());
assertEquals("5.2.1.3 (r123456-b0) schema 10051", versionInfo.getDisplay());
// Check license info
LicenseInfo licenseInfo = repositoryInfo.getLicense();
assertNotNull(licenseInfo);
assertEquals(LicenseMode.ENTERPRISE.name(), licenseInfo.getMode());
assertEquals(licenseIssuedAt.toString(), licenseInfo.getIssuedAt().toString());
assertEquals(licenseExpiresAt.toString(), licenseInfo.getExpiresAt().toString());
assertEquals(Integer.valueOf(5), licenseInfo.getRemainingDays());
assertEquals("Alfresco Dev Test", licenseInfo.getHolder());
LicenseEntitlement entitlements = licenseInfo.getEntitlements();
assertNotNull(entitlements);
assertNotNull(entitlements.getMaxUsers());
assertEquals(20L, entitlements.getMaxUsers().longValue());
assertNotNull(entitlements.getMaxDocs());
assertEquals(1000L, entitlements.getMaxDocs().longValue());
assertTrue(entitlements.getIsClusterEnabled());
assertFalse(entitlements.getIsCryptodocEnabled());
// Check status
StatusInfo statusInfo = repositoryInfo.getStatus();
assertNotNull(statusInfo);
assertFalse(statusInfo.getIsReadOnly());
assertTrue(statusInfo.getIsAuditEnabled());
assertTrue(statusInfo.getIsQuickShareEnabled());
assertTrue(statusInfo.getIsThumbnailGenerationEnabled());
// Check modules
List<ModulePackage> modulePackageList = repositoryInfo.getModules();
assertNotNull(modulePackageList);
}
use of org.alfresco.rest.api.model.DiscoveryDetails in project alfresco-remote-api by Alfresco.
the class DiscoveryApiTest method testGetDiscovery_licenseEntitlement.
/**
* Tests get discovery.
* <p>GET:</p>
* {@literal <host>:<port>/alfresco/api/discovery}
*/
@Test
public void testGetDiscovery_licenseEntitlement() throws Exception {
// Override maxUsers
when(licenseDescriptorMock.getMaxUsers()).thenReturn(null);
setRequestContext(null, user1, null);
HttpResponse response = get("discovery", null, 200);
DiscoveryDetails discoveryDetails = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), DiscoveryDetails.class);
assertNotNull(discoveryDetails);
RepositoryInfo repositoryInfo = discoveryDetails.getRepository();
assertNotNull(repositoryInfo);
assertEquals("Enterprise", repositoryInfo.getEdition());
// Check license info
LicenseInfo licenseInfo = repositoryInfo.getLicense();
assertNotNull(licenseInfo);
assertEquals(LicenseMode.ENTERPRISE.name(), licenseInfo.getMode());
assertEquals(licenseIssuedAt.toString(), licenseInfo.getIssuedAt().toString());
assertEquals(licenseExpiresAt.toString(), licenseInfo.getExpiresAt().toString());
assertEquals(Integer.valueOf(5), licenseInfo.getRemainingDays());
assertEquals("Alfresco Dev Test", licenseInfo.getHolder());
LicenseEntitlement entitlements = licenseInfo.getEntitlements();
assertNotNull(entitlements);
assertNull(entitlements.getMaxUsers());
assertEquals(1000L, entitlements.getMaxDocs().longValue());
assertTrue(entitlements.getIsClusterEnabled());
assertFalse(entitlements.getIsCryptodocEnabled());
// Override entitlements
when(licenseDescriptorMock.getMaxDocs()).thenReturn(null);
when(licenseDescriptorMock.isClusterEnabled()).thenReturn(false);
when(licenseDescriptorMock.isCryptodocEnabled()).thenReturn(true);
response = get("discovery", null, 200);
discoveryDetails = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), DiscoveryDetails.class);
assertNotNull(discoveryDetails);
repositoryInfo = discoveryDetails.getRepository();
assertNotNull(repositoryInfo);
// Check license info
licenseInfo = repositoryInfo.getLicense();
assertNotNull(licenseInfo);
entitlements = licenseInfo.getEntitlements();
assertNotNull(entitlements);
assertNull(entitlements.getMaxUsers());
assertNull(entitlements.getMaxDocs());
assertFalse(entitlements.getIsClusterEnabled());
assertTrue(entitlements.getIsCryptodocEnabled());
}
use of org.alfresco.rest.api.model.DiscoveryDetails in project alfresco-remote-api by Alfresco.
the class DiscoveryApiWebscript method execute.
@Override
public void execute(WebScriptRequest webScriptRequest, WebScriptResponse webScriptResponse) throws IOException {
try {
checkEnabled();
DiscoveryDetails discoveryDetails = new DiscoveryDetails(getRepositoryInfo());
// Write response
setResponse(webScriptResponse, DEFAULT_SUCCESS);
renderJsonResponse(webScriptResponse, discoveryDetails, assistant.getJsonHelper());
} catch (Exception exception) {
renderException(exception, webScriptResponse, assistant);
}
}
use of org.alfresco.rest.api.model.DiscoveryDetails in project alfresco-remote-api by Alfresco.
the class DiscoveryApiTest method testGetDiscovery_hotfixValue.
/**
* Tests get discovery.
* <p>GET:</p>
* {@literal <host>:<port>/alfresco/api/discovery}
*/
@Test
public void testGetDiscovery_hotfixValue() throws Exception {
/*
* The agreement was that if the hotfix value (versionLabel) does not follow the standard
* of "dot then digits" or just "digits", the API should return zero.
*/
when(serverDescriptor.getVersionLabel()).thenReturn("4");
setRequestContext(null, user1, null);
HttpResponse response = get("discovery", null, 200);
DiscoveryDetails discoveryDetails = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), DiscoveryDetails.class);
assertNotNull(discoveryDetails);
RepositoryInfo repositoryInfo = discoveryDetails.getRepository();
assertNotNull(repositoryInfo);
assertEquals("Enterprise", repositoryInfo.getEdition());
// Check version info
VersionInfo versionInfo = repositoryInfo.getVersion();
assertNotNull(versionInfo);
assertEquals("5", versionInfo.getMajor());
assertEquals("2", versionInfo.getMinor());
assertEquals("1", versionInfo.getPatch());
assertEquals("4", versionInfo.getHotfix());
assertEquals("r123456-b0", versionInfo.getLabel());
assertEquals(10051, versionInfo.getSchema());
assertEquals("5.2.1.4 (r123456-b0) schema 10051", versionInfo.getDisplay());
when(serverDescriptor.getVersionLabel()).thenReturn("d");
response = get("discovery", null, 200);
discoveryDetails = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), DiscoveryDetails.class);
assertNotNull(discoveryDetails);
repositoryInfo = discoveryDetails.getRepository();
assertNotNull(repositoryInfo);
// Check version info
versionInfo = repositoryInfo.getVersion();
assertNotNull(versionInfo);
assertEquals("5", versionInfo.getMajor());
assertEquals("2", versionInfo.getMinor());
assertEquals("1", versionInfo.getPatch());
assertEquals("0", versionInfo.getHotfix());
assertEquals("r123456-b0", versionInfo.getLabel());
assertEquals(10051, versionInfo.getSchema());
assertEquals("5.2.1.0 (r123456-b0) schema 10051", versionInfo.getDisplay());
when(serverDescriptor.getVersionLabel()).thenReturn("39.4");
response = get("discovery", null, 200);
discoveryDetails = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), DiscoveryDetails.class);
assertNotNull(discoveryDetails);
repositoryInfo = discoveryDetails.getRepository();
assertNotNull(repositoryInfo);
// Check version info
versionInfo = repositoryInfo.getVersion();
assertNotNull(versionInfo);
assertEquals("5", versionInfo.getMajor());
assertEquals("2", versionInfo.getMinor());
assertEquals("1", versionInfo.getPatch());
assertEquals("0", versionInfo.getHotfix());
assertEquals("r123456-b0", versionInfo.getLabel());
assertEquals(10051, versionInfo.getSchema());
assertEquals("5.2.1.0 (r123456-b0) schema 10051", versionInfo.getDisplay());
}
Aggregations