Package com.tll.model.test

Examples of com.tll.model.test.Account


    modules.add(new TestPersistenceUnitModelModule());
  }

  private Account getTestEntity() {
    final EntityBeanFactory ebf = injector.getInstance(EntityBeanFactory.class);
    final Account account = ebf.getEntityCopy(Account.class, true);
    final Account parent = ebf.getEntityCopy(Account.class, true);
    final AccountAddress aa1 = ebf.getEntityCopy(AccountAddress.class, true);
    final AccountAddress aa2 = ebf.getEntityCopy(AccountAddress.class, true);

    account.setParent(parent);
    account.addAccountAddress(aa1);
View Full Code Here


    return account;
  }

  @SuppressWarnings("unused")
  private ConstraintViolation<Account> getTestConstraintViolation() {
    final Account account = getTestEntity();
    final AccountAddress accountAddress = account.getAddresses().iterator().next();

    final PathImpl path = PathImpl.createPathFromString("addresses[].address.lastName");

    return
    new ConstraintViolationImpl<Account>(null, "error msg", Account.class, account, accountAddress, null,
View Full Code Here

  @Override
  protected Model entityToModel(IEntityType entityType, IEntity e) throws Exception {
    final Model m = super.entityToModel(entityType, e);
    assert m != null;
    final Account a = (Account) e;
    if(a.getParent() != null) {
      final PrimaryKey<Account> pk = new PrimaryKey<Account>(Account.class, a.getParent().getId());
      final IAccountService svc = context.getEntityServiceFactory().instance(IAccountService.class);
      final Account parent = svc.load(pk);
      final Model mparent = new Model(TestEntityType.ACCOUNT);
      mparent.set(new StringPropertyValue(Model.ID_PROPERTY, parent.getId()));
      mparent.set(new StringPropertyValue(Model.NAME_PROPERTY, parent.getName()));
      m.set(new RelatedOneProperty(TestEntityType.ACCOUNT, mparent, "parent", true));
    }
    return m;
  }
View Full Code Here

    NestedEntity nestedEntity = create(NestedEntity.class, true);
    nestedEntity = persist(nestedEntity);
    pkNestedEntity = nestedEntity.getId();

    Account parent = create(Account.class, true);
    parent.setName("parent account");
    parent.setParent(null); // eliminate pointer chasing
    parent.setCurrency(currency);
    parent.setNestedEntity(nestedEntity);
    parent = persist(parent);
    pkAccountParent = parent.getId();
  }
View Full Code Here

    // wire up a circular entity
    final Collection<Account> accounts = entityGraph.getEntitiesByType(Account.class);
    // NOTE: we expect 3 of them per test-persistence-unit jar
    final Iterator<Account> aitr = accounts.iterator();
    final Account account = aitr.next(), parent = aitr.next();
    account.setParent(parent);
    parent.setParent(account);

    final Model model = marshaler.marshalEntity(account, MarshalOptions.UNCONSTRAINED_MARSHALING);
    Assert.assertTrue(model != null);
    final Account unmarshaled = marshaler.marshalModel(model, Account.class);
    Assert.assertTrue(unmarshaled != null);
    Assert.assertEquals(account, unmarshaled);
  }
View Full Code Here

   * @throws Exception
   */
  public void testEmptyRelatedMany() throws Exception {
    final Marshaler marshaler = getMarshaler();
    Assert.assertTrue(marshaler != null);
    final Account e = getEntityBeanFactory().getEntityCopy(Account.class, false);
    Assert.assertTrue(e != null);
    e.setAddresses(null);
    final Model m = marshaler.marshalEntity(e, MarshalOptions.UNCONSTRAINED_MARSHALING);
    Assert.assertTrue(m != null);
    final IModelProperty mp = m.get("addresses");
    Assert.assertTrue(mp != null);
  }
View Full Code Here

  }

  public void testEmptyNested() throws Exception {
    final Marshaler marshaler = getMarshaler();
    Assert.assertTrue(marshaler != null);
    final Account e = getEntityBeanFactory().getEntityCopy(Account.class, false);
    final NestedEntity n = getEntityBeanFactory().getEntityCopy(NestedEntity.class, false);
    Assert.assertTrue(e != null && n != null);
    e.setNestedEntity(n);
    final Model m = marshaler.marshalEntity(e, MarshalOptions.UNCONSTRAINED_MARSHALING);
    Assert.assertTrue(m != null);
    final IModelProperty mp = m.get("nestedEntity");
    Assert.assertTrue(mp != null);
  }
View Full Code Here

  }

  public void testEmptyNestedTarget() throws Exception {
    final Marshaler marshaler = getMarshaler();
    Assert.assertTrue(marshaler != null);
    final Account e = getEntityBeanFactory().getEntityCopy(Account.class, false);
    final NestedEntity n = getEntityBeanFactory().getEntityCopy(NestedEntity.class, false);
    Assert.assertTrue(e != null && n != null);
    e.setNestedEntity(n);
    e.getNestedEntity().setNestedData(null);
    final Model m = marshaler.marshalEntity(e, MarshalOptions.UNCONSTRAINED_MARSHALING);
    Assert.assertTrue(m != null);
    final IModelProperty mp = m.get("nestedEntity");
    Assert.assertTrue(mp != null);
  }
View Full Code Here

  }

  public void testUnmarshalAgainstExistingEntity() throws Exception {
    final Marshaler marshaler = getMarshaler();
    Assert.assertTrue(marshaler != null);
    final Account e = getEntityBeanFactory().getEntityCopy(Account.class, false);
    e.setVersion(1);
    final AccountAddress aa1 = getEntityBeanFactory().getEntityCopy(AccountAddress.class, false);
    final AccountAddress aa2 = getEntityBeanFactory().getEntityCopy(AccountAddress.class, true);
    e.addAccountAddress(aa1);
    e.addAccountAddress(aa2);

    final Model m = marshaler.marshalEntity(e, MarshalOptions.UNCONSTRAINED_MARSHALING);
    m.indexed("addresses[0]").getModel().setMarkedDeleted(true);

    final Account rea = marshaler.marshalModel(m, e);
    Assert.assertTrue(e == rea);
    Assert.assertTrue(e.equals(rea));
    Assert.assertEquals(rea.getVersion(), m.getProperty(Model.VERSION_PROPERTY));
    Assert.assertTrue(e.getAddresses() != null);
    Assert.assertTrue(e.getAddresses().size() == 1);
    Assert.assertTrue(e.getAddresses().iterator().next().equals(aa2));
  }
View Full Code Here

    NestedEntity nestedEntity = create(NestedEntity.class, true);
    nestedEntity = persist(nestedEntity);
    pkNestedEntity = new PrimaryKey<NestedEntity>(nestedEntity);

    Account parent = create(Account.class, true);
    parent.setParent(null); // eliminate pointer chasing
    parent.setCurrency(currency);
    parent.setNestedEntity(nestedEntity);
    parent = persist(parent);
    pkAccountParent = new PrimaryKey<Account>(parent);
  }
View Full Code Here

TOP

Related Classes of com.tll.model.test.Account

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.