Search in sources :

Example 1 with ShortAccountDTO

use of org.geosdi.geoplatform.response.ShortAccountDTO in project geo-platform by geosdi.

the class WSAccountTest method testAllOrganizationAccounts.

@Test
public void testAllOrganizationAccounts() throws Exception {
    // Initial test
    List<ShortAccountDTO> accountList = gpWSClient.getAccounts(organizationNameTest).getAccounts();
    assertNotNull(accountList);
    int numAccounts = accountList.size();
    logger.info("\n*** Number of Accounts for Organization \"{}\": {} ***", organizationNameTest, numAccounts);
    for (ShortAccountDTO account : accountList) {
        assertEquals(organizationNameTest, account.getOrganization());
    }
    // Insert User of the organization for test
    this.createAndInsertUser("to_search", organizationTest, USER);
    // Insert the other Organization and a User for it
    GPOrganization otherOrganization = new GPOrganization("other_organization_ws_test");
    Long otherOrganizationID = gpWSClient.insertOrganization(otherOrganization);
    this.createAndInsertUser("none_search", otherOrganization, USER);
    // Final test
    accountList = gpWSClient.getAccounts(organizationNameTest).getAccounts();
    assertNotNull(accountList);
    assertEquals(numAccounts + 1, accountList.size());
    for (ShortAccountDTO account : accountList) {
        assertEquals(organizationNameTest, account.getOrganization());
    }
    // Delete the other Organization
    gpWSClient.deleteOrganization(otherOrganizationID);
}
Also used : ShortAccountDTO(org.geosdi.geoplatform.response.ShortAccountDTO) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) Test(org.junit.Test)

Example 2 with ShortAccountDTO

use of org.geosdi.geoplatform.response.ShortAccountDTO in project geo-platform by geosdi.

the class RSAccountTest method testAllOrganizationAccountsRest.

@Test
public void testAllOrganizationAccountsRest() throws Exception {
    // Initial test
    List<ShortAccountDTO> accountList = gpWSClient.getAccounts(organizationNameRSTest).getAccounts();
    Assert.assertNotNull(accountList);
    int numAccounts = accountList.size();
    logger.info("\n*** Number of Accounts for Organization \"{}\": {} ***", organizationNameRSTest, numAccounts);
    for (ShortAccountDTO account : accountList) {
        Assert.assertEquals(organizationNameRSTest, account.getOrganization());
    }
    // Insert User of the organization for test
    this.createAndInsertUser("to_search", organizationTest, GPRole.USER);
    // Insert the other Organization and a User for it
    GPOrganization otherOrganization = new GPOrganization("other_organization_ws_test");
    Long otherOrganizationID = gpWSClient.insertOrganization(otherOrganization);
    this.createAndInsertUser("none_search", otherOrganization, GPRole.USER);
    // Final test
    accountList = gpWSClient.getAccounts(organizationNameRSTest).getAccounts();
    Assert.assertNotNull(accountList);
    Assert.assertEquals(numAccounts + 1, accountList.size());
    for (ShortAccountDTO account : accountList) {
        Assert.assertEquals(organizationNameRSTest, account.getOrganization());
    }
    // Delete the other Organization
    gpWSClient.deleteOrganization(otherOrganizationID);
}
Also used : ShortAccountDTO(org.geosdi.geoplatform.response.ShortAccountDTO) GPOrganization(org.geosdi.geoplatform.core.model.GPOrganization) Test(org.junit.Test)

Example 3 with ShortAccountDTO

use of org.geosdi.geoplatform.response.ShortAccountDTO in project geo-platform by geosdi.

the class ShortAccountDTOFactoryMassiveTest method testShortAccountFactory.

@Test
public void testShortAccountFactory() throws InterruptedException, ExecutionException {
    ExecutorService executor = Executors.newFixedThreadPool(2);
    List<Callable<ShortAccountDTO>> tasks = new ArrayList<Callable<ShortAccountDTO>>(1000);
    for (int i = 0; i < 1000; i++) {
        if (i < 500) {
            tasks.add(new CallableEntity(createGPUser(i)));
        } else {
            tasks.add(new CallableEntity(createGPApplication(i)));
        }
    }
    List<Future<ShortAccountDTO>> results = executor.invokeAll(tasks);
    executor.shutdown();
    boolean flag = executor.awaitTermination(1, TimeUnit.MINUTES);
    if (flag) {
        for (Future<ShortAccountDTO> future : results) {
            logger.info("@@@@@@@@@@@@@@@@@@@@@@@@@@@@ {}\n", future.get());
        }
    } else {
        throw new InterruptedException("Some Threads are not executed.");
    }
}
Also used : ShortAccountDTO(org.geosdi.geoplatform.response.ShortAccountDTO) ExecutorService(java.util.concurrent.ExecutorService) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Example 4 with ShortAccountDTO

use of org.geosdi.geoplatform.response.ShortAccountDTO in project geo-platform by geosdi.

the class AccountDTOFactory method buildShortAccountDTOList.

/**
 * @param accounts
 * @return {@link List<ShortAccountDTO>}
 */
public static List<ShortAccountDTO> buildShortAccountDTOList(List<GPAccount> accounts) {
    checkNotNull(accounts, "The List of Accounts " + "must not be null.");
    List<ShortAccountDTO> accountsDTO = new ArrayList<>(accounts.size());
    for (GPAccount account : accounts) {
        accountsDTO.add(buildAccountDTO(account));
    }
    return accountsDTO;
}
Also used : GPAccount(org.geosdi.geoplatform.core.model.GPAccount) ShortAccountDTO(org.geosdi.geoplatform.response.ShortAccountDTO) ArrayList(java.util.ArrayList)

Example 5 with ShortAccountDTO

use of org.geosdi.geoplatform.response.ShortAccountDTO in project geo-platform by geosdi.

the class WSAccountTest method testAllAccounts.

@Test
public void testAllAccounts() {
    List<ShortAccountDTO> accountList = gpWSClient.getAllAccounts().getAccounts();
    assertNotNull(accountList);
    logger.info("\n*** Number of Accounts into DB: {} ***", accountList.size());
    for (ShortAccountDTO account : accountList) {
        if (account instanceof UserDTO) {
            logger.info("\n*** User into DB:\n{}\n***", (UserDTO) account);
        } else if (account instanceof ApplicationDTO) {
            logger.info("\n*** Application into DB:\n{}\n***", (ApplicationDTO) account);
        }
    }
}
Also used : ApplicationDTO(org.geosdi.geoplatform.response.ApplicationDTO) ShortAccountDTO(org.geosdi.geoplatform.response.ShortAccountDTO) UserDTO(org.geosdi.geoplatform.response.UserDTO) Test(org.junit.Test)

Aggregations

ShortAccountDTO (org.geosdi.geoplatform.response.ShortAccountDTO)6 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)2 GPOrganization (org.geosdi.geoplatform.core.model.GPOrganization)2 ApplicationDTO (org.geosdi.geoplatform.response.ApplicationDTO)2 UserDTO (org.geosdi.geoplatform.response.UserDTO)2 Callable (java.util.concurrent.Callable)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 GPAccount (org.geosdi.geoplatform.core.model.GPAccount)1