Search in sources :

Example 1 with ModulePackage

use of org.alfresco.rest.api.model.ModulePackage 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);
}
Also used : VersionInfo(org.alfresco.rest.api.model.RepositoryInfo.VersionInfo) LicenseInfo(org.alfresco.rest.api.model.RepositoryInfo.LicenseInfo) ModulePackage(org.alfresco.rest.api.model.ModulePackage) RepositoryInfo(org.alfresco.rest.api.model.RepositoryInfo) StatusInfo(org.alfresco.rest.api.model.RepositoryInfo.StatusInfo) LicenseEntitlement(org.alfresco.rest.api.model.RepositoryInfo.LicenseEntitlement) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) DiscoveryDetails(org.alfresco.rest.api.model.DiscoveryDetails) Test(org.junit.Test) AbstractSingleNetworkSiteTest(org.alfresco.rest.AbstractSingleNetworkSiteTest)

Example 2 with ModulePackage

use of org.alfresco.rest.api.model.ModulePackage in project alfresco-remote-api by Alfresco.

the class ModulePackagesApiTest method testAllModulePackages.

@Test
public void testAllModulePackages() throws Exception {
    setRequestContext(nonAdminUserName);
    HttpResponse response = getAll(MODULEPACKAGES, null, HttpStatus.SC_OK);
    assertNotNull(response);
    PublicApiClient.ExpectedPaging paging = parsePaging(response.getJsonResponse());
    assertNotNull(paging);
    if (paging.getCount() > 0) {
        List<ModulePackage> modules = parseRestApiEntries(response.getJsonResponse(), ModulePackage.class);
        assertNotNull(modules);
        assertEquals(paging.getCount().intValue(), modules.size());
    }
}
Also used : ModulePackage(org.alfresco.rest.api.model.ModulePackage) HttpResponse(org.alfresco.rest.api.tests.client.HttpResponse) PublicApiClient(org.alfresco.rest.api.tests.client.PublicApiClient) Test(org.junit.Test)

Example 3 with ModulePackage

use of org.alfresco.rest.api.model.ModulePackage in project alfresco-remote-api by Alfresco.

the class DiscoveryApiWebscript method getModules.

private List<ModulePackage> getModules() {
    List<ModuleDetails> details = moduleService.getAllModules();
    if (details.isEmpty()) {
        return null;
    }
    List<ModulePackage> packages = new ArrayList<>(details.size());
    for (ModuleDetails detail : details) {
        packages.add(ModulePackage.fromModuleDetails(detail));
    }
    return packages;
}
Also used : ModulePackage(org.alfresco.rest.api.model.ModulePackage) ArrayList(java.util.ArrayList) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails)

Example 4 with ModulePackage

use of org.alfresco.rest.api.model.ModulePackage in project alfresco-remote-api by Alfresco.

the class ModulePackageTest method testConstructor.

@Test
public void testConstructor() throws IOException {
    ModuleDetails details = new ModuleDetailsImpl(props);
    ModulePackage modulePackage = ModulePackage.fromModuleDetails(details);
    assertNotNull(modulePackage);
    assertEquals(props.getProperty(ModuleDetails.PROP_ID), modulePackage.getId());
    assertEquals(props.getProperty(ModuleDetails.PROP_VERSION), modulePackage.getVersion());
    assertEquals(props.getProperty(ModuleDetails.PROP_REPO_VERSION_MIN), modulePackage.getVersionMin());
    assertEquals(props.getProperty(ModuleDetails.PROP_REPO_VERSION_MAX), modulePackage.getVersionMax());
    assertEquals(props.getProperty(ModuleDetails.PROP_INSTALL_STATE), modulePackage.getInstallState().toString());
}
Also used : ModuleDetailsImpl(org.alfresco.repo.module.ModuleDetailsImpl) ModulePackage(org.alfresco.rest.api.model.ModulePackage) ModuleDetails(org.alfresco.service.cmr.module.ModuleDetails) Test(org.junit.Test) ModuleDetailsImplTest(org.alfresco.repo.module.ModuleDetailsImplTest)

Example 5 with ModulePackage

use of org.alfresco.rest.api.model.ModulePackage in project alfresco-remote-api by Alfresco.

the class ModulePackageTest method testInvalidConstructor.

@Test
public void testInvalidConstructor() throws IOException {
    ModulePackage modulePackage = ModulePackage.fromModuleDetails(null);
    assertNull(modulePackage);
}
Also used : ModulePackage(org.alfresco.rest.api.model.ModulePackage) Test(org.junit.Test) ModuleDetailsImplTest(org.alfresco.repo.module.ModuleDetailsImplTest)

Aggregations

ModulePackage (org.alfresco.rest.api.model.ModulePackage)6 Test (org.junit.Test)5 HttpResponse (org.alfresco.rest.api.tests.client.HttpResponse)3 ModuleDetailsImplTest (org.alfresco.repo.module.ModuleDetailsImplTest)2 ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)2 ArrayList (java.util.ArrayList)1 ModuleDetailsImpl (org.alfresco.repo.module.ModuleDetailsImpl)1 AbstractSingleNetworkSiteTest (org.alfresco.rest.AbstractSingleNetworkSiteTest)1 DiscoveryDetails (org.alfresco.rest.api.model.DiscoveryDetails)1 RepositoryInfo (org.alfresco.rest.api.model.RepositoryInfo)1 LicenseEntitlement (org.alfresco.rest.api.model.RepositoryInfo.LicenseEntitlement)1 LicenseInfo (org.alfresco.rest.api.model.RepositoryInfo.LicenseInfo)1 StatusInfo (org.alfresco.rest.api.model.RepositoryInfo.StatusInfo)1 VersionInfo (org.alfresco.rest.api.model.RepositoryInfo.VersionInfo)1 PublicApiClient (org.alfresco.rest.api.tests.client.PublicApiClient)1