Search in sources :

Example 1 with Organization

use of org.eclipse.kapua.service.account.Organization in project kapua by eclipse.

the class AccountServiceTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    // KapuaPeid accountPeid = KapuaEidGenerator.generate();//
    KapuaId scopeId = new KapuaEid(BigInteger.valueOf(1));
    KapuaLocator locator = KapuaLocator.getInstance();
    long accountSerial = (new Date()).getTime();
    AccountCreator accountCreator = this.getTestAccountCreator(scopeId, accountSerial);
    AccountService accountService = locator.getService(AccountService.class);
    Account account = accountService.create(accountCreator);
    account = accountService.find(account.getScopeId(), account.getId());
    Organization org = account.getOrganization();
    org.setAddressLine1("5th evenue, NY");
    account.setOrganization(org);
    Account accountUpd = accountService.update(account);
    // 
    // Account asserts
    assertNotNull(accountUpd);
    assertNotNull(accountUpd.getId());
    assertNotNull(accountUpd.getId().getId());
    assertTrue(accountUpd.getOptlock() >= 0);
    assertTrue(accountUpd.getId().equals(account.getId()));
    assertTrue(accountUpd.getScopeId().equals(account.getScopeId()));
    assertTrue(accountUpd.getName().equals(account.getName()));
    assertNotNull(accountUpd.getOrganization());
    assertTrue(accountUpd.getOrganization().getAddressLine1().equals(org.getAddressLine1()));
    assertNotNull(accountUpd.getCreatedOn().equals(account.getCreatedOn()));
    assertNotNull(accountUpd.getCreatedBy().equals(account.getCreatedBy()));
    assertNotNull(account.getModifiedOn());
    assertNotNull(account.getModifiedBy());
}
Also used : AccountCreator(org.eclipse.kapua.service.account.AccountCreator) KapuaLocator(org.eclipse.kapua.locator.KapuaLocator) Account(org.eclipse.kapua.service.account.Account) Organization(org.eclipse.kapua.service.account.Organization) KapuaId(org.eclipse.kapua.model.id.KapuaId) KapuaEid(org.eclipse.kapua.commons.model.id.KapuaEid) AccountService(org.eclipse.kapua.service.account.AccountService) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Date (java.util.Date)1 KapuaEid (org.eclipse.kapua.commons.model.id.KapuaEid)1 KapuaLocator (org.eclipse.kapua.locator.KapuaLocator)1 KapuaId (org.eclipse.kapua.model.id.KapuaId)1 Account (org.eclipse.kapua.service.account.Account)1 AccountCreator (org.eclipse.kapua.service.account.AccountCreator)1 AccountService (org.eclipse.kapua.service.account.AccountService)1 Organization (org.eclipse.kapua.service.account.Organization)1 Test (org.junit.Test)1