Package siena.base.test.model

Examples of siena.base.test.model.AggregateChildModel


  public void testAggregateMostSimple() {
    AggregateParentModel god = new AggregateParentModel("god");
    god.insert();
    assertNotNull(god.id);
   
    AggregateChildModel adam1 = new AggregateChildModel("adam1");
    adam1.aggregate(god, "child");
    adam1.insert();
   
    assertNotNull(adam1.id);
    assertNotNull(adam1.getRelation());

    AggregateParentModel god1 =
      Model.getByKey(AggregateParentModel.class, god.id);
    assertNotNull(god1);
    assertEquals(adam1, god1.child.get());
   
    adam1.name = "adam1_UPD";
    adam1.update();
   
    assertEquals(adam1, god1.child.forceSync().get());
   
    adam1.name = "adam1_UPD2";
    adam1.save();
   
    assertEquals(adam1, god1.child.forceSync().get());
   
    AggregateChildModel adam2 = new AggregateChildModel("adam2");
    adam2.aggregate(god, "child");
    adam2.save();
   
    assertEquals(adam1, god1.child.forceSync().get());
   
    god1.child.set(adam2);
    god1.update();

    AggregateParentModel god2 =
      Model.getByKey(AggregateParentModel.class, god1.id);
    assertNotNull(god2);
    assertEquals(adam2, god2.child.get());
   
    AggregateChildModel adam3 = new AggregateChildModel("adam3");
    adam3.aggregate(god, "child");
    adam3.save();
   
    god.child.set(adam3);
    god.update();
   
    AggregateParentModel god3 =
      Model.getByKey(AggregateParentModel.class, god.id);
    assertNotNull(god3);
    assertEquals(adam2, god3.child.get());
   
    god.child.forceSync().set(adam3);
    god.update();
   
    god3 =
      Model.getByKey(AggregateParentModel.class, god.id);
    assertNotNull(god3);
    assertEquals(adam3, god3.child.get());
   
    adam3.delete();
    assertNull(god3.child.forceSync().get());
  }
View Full Code Here


  public void testAggregateMostSimpleMultiple() {
    AggregateParentModel god = new AggregateParentModel("god");
    god.insert();
    assertNotNull(god.id);

    AggregateChildModel adam1 = new AggregateChildModel("adam1");
    adam1.aggregate(god, "child");
    adam1.insert();
   
    AggregateChildModel adam2 = new AggregateChildModel("adam2")
    adam2.aggregate(god, "children");
    adam2.insert();

    AggregateChildModel eve = new AggregateChildModel("eve");
    eve.aggregate(god, "children");
    eve.insert();

    AggregateChildModel bob = new AggregateChildModel("bob");
    bob.aggregate(god, "children");
    bob.insert();

    AggregateParentModel god1 =
      Model.getByKey(AggregateParentModel.class, god.id);
   
    assertNotNull(god1);
View Full Code Here

    assertEquals(adam2, children.get(0));
    assertEquals(bob, children.get(1));
  }
 
  public void testAggregate() {
    AggregateChildModel adam1 = new AggregateChildModel("adam1");
    AggregateChildModel adam2 = new AggregateChildModel("adam2")
    AggregateChildModel eve = new AggregateChildModel("eve");
    AggregateChildModel bob = new AggregateChildModel("bob");

    AggregateParentModel god = new AggregateParentModel("god");
    god.child.set(adam1);
    god.children.asList().addAll(adam2, eve, bob);       
    god.insert();
   
    assertNotNull(god.id);
    assertNotNull(god.child.get().id);
   
    AggregateParentModel god1 =
      Model.getByKey(AggregateParentModel.class, god.id);
   
    assertNotNull(god1);
    assertEquals(adam1, god1.child.get());
    List<AggregateChildModel> children = god1.children.asQuery().fetch();
    assertEquals(adam2, children.get(0));
    assertEquals(eve, children.get(1));
    assertEquals(bob, children.get(2));
   
    // get aggregated one2one
    AggregateChildModel adamAfter2 = AggregateChildModel.all().aggregated(god, "child").get();
    assertEquals(adam1, adamAfter2);
   
    // get aggregated one2many
    children = AggregateChildModel.all().aggregated(god, "children").fetch();
    assertEquals(adam2, children.get(0));
View Full Code Here

    assertEquals(eve, children.get(1));
    assertEquals(bob, children.get(2));
  }
 
  public void testAggregateUpdate() {
    AggregateChildModel adam1 = new AggregateChildModel("adam1");
    AggregateChildModel adam2 = new AggregateChildModel("adam2")
    AggregateChildModel eve = new AggregateChildModel("eve");
    AggregateChildModel bob = new AggregateChildModel("bob");

    AggregateParentModel god = new AggregateParentModel("god");
    god.child.set(adam1);
    god.children.asList().addAll(Arrays.asList(adam2, eve, bob));
       
    god.insert();
   
    assertNotNull(god.id);
    assertNotNull(god.child.get().id);
   
    god.name = "goddy";
    adam1.name = "adammy";
    adam1.save();
    bob.name = "bobby";
    bob.save();
    eve.name = "evvy";
    eve.save();
   
    god.update();
   
View Full Code Here

    assertEquals(adam2, children.get(0));
    assertEquals(bob, children.get(1));
  }
 
  public void testAggregateSave() {
    AggregateChildModel adam1 = new AggregateChildModel("adam1");
    AggregateChildModel adam2 = new AggregateChildModel("adam2")
    AggregateChildModel eve = new AggregateChildModel("eve");
    AggregateChildModel bob = new AggregateChildModel("bob");

    AggregateParentModel god = new AggregateParentModel("god");
    god.child.set(adam1);
    god.children.asList().addAll(Arrays.asList(adam2, eve, bob));
       
View Full Code Here

    assertEquals(adam2, children.get(0));
    assertEquals(bob, children.get(1));
  }
 
  public void testAggregateDelete() {
    AggregateChildModel adam1 = new AggregateChildModel("adam1");
    AggregateChildModel adam2 = new AggregateChildModel("adam2")
    AggregateChildModel eve = new AggregateChildModel("eve");
    AggregateChildModel bob = new AggregateChildModel("bob");

    AggregateParentModel god = new AggregateParentModel("god");
    god.child.set(adam1);
    god.children.asList().addAll(Arrays.asList(adam2, eve, bob));
       
View Full Code Here

    assertEquals(null, children.get(2));
    assertEquals(null, children.get(3));
  }
 
  public void testAggregateDeleteChildOfChildren() {
    AggregateChildModel adam1 = new AggregateChildModel("adam1");
    AggregateChildModel adam2 = new AggregateChildModel("adam2")
    AggregateChildModel eve = new AggregateChildModel("eve");
    AggregateChildModel bob = new AggregateChildModel("bob");

    AggregateParentModel god = new AggregateParentModel("god");
    god.child.set(adam1);
    god.children.asList().addAll(Arrays.asList(adam2, eve, bob));
       
View Full Code Here

    assertEquals(adam2, children.get(0));
    assertEquals(bob, children.get(1));
  }
 
  public void testAggregateAddChild() {
    AggregateChildModel adam1 = new AggregateChildModel("adam1");
    AggregateChildModel adam2 = new AggregateChildModel("adam2")
    AggregateChildModel eve = new AggregateChildModel("eve");
    AggregateChildModel bob = new AggregateChildModel("bob");
    AggregateChildModel eve2 = new AggregateChildModel("eve2");

    AggregateParentModel god = new AggregateParentModel("god");
    god.child.set(adam1);
    god.children.asList().addAll(Arrays.asList(adam2, eve, bob));
       
View Full Code Here

  }
 
  public void testAggregateListQuerysFetch() {
    List<AggregateChildModel> adams = new ArrayList<AggregateChildModel>();
    for(int i=0; i<100; i++){
      AggregateChildModel adam = new AggregateChildModel();
      adam.name = "adam"+i;
      adams.add(adam);
    }
   
    AggregateChildModel eve = new AggregateChildModel("eve");

    AggregateParentModel god = new AggregateParentModel("god");
    god.child.set(eve);
    god.children.asList().addAll(adams);
       
View Full Code Here

  }
 
  public void testAggregateListQuerysFetchLimit() {
    List<AggregateChildModel> adams = new ArrayList<AggregateChildModel>();
    for(int i=0; i<100; i++){
      AggregateChildModel adam = new AggregateChildModel();
      adam.name = "adam"+i;
      adams.add(adam);
    }
   
    AggregateChildModel eve = new AggregateChildModel();
    eve.name = "eve";

    AggregateParentModel god = new AggregateParentModel();
    god.name = "god";
    god.child.set(eve);
View Full Code Here

TOP

Related Classes of siena.base.test.model.AggregateChildModel

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.