Examples of PojoWithListInnerObject


Examples of org.monjo.example.PojoWithListInnerObject

  public static PojoWithListInnerObject createMegaZordePojo() {
    Category category = new Category();
    category.setName("NewCategory");
 
    PojoWithListInnerObject pojo = new PojoWithListInnerObject();
    LinkedList<Category> categories = new LinkedList<Category>();
    categories.add(category);
    pojo.setCategories(categories);
    return pojo;
  }
View Full Code Here

Examples of org.monjo.example.PojoWithListInnerObject

    Assert.assertTrue(integers.contains(20));
  }
 
  @Test
  public void shouldNotUseRef() throws Exception {
    PojoWithListInnerObject pojo = PojoBuilder.createMegaZordePojo();
    Monjo<ObjectId, PojoWithListInnerObject> monjoComplex = new Monjo<ObjectId, PojoWithListInnerObject>(getMongoDB(),
        PojoWithListInnerObject.class);

    monjoComplex.removeAll();
    monjoComplex.insert(pojo);
    assertNotNull(pojo.getCategories().get(0).getId());
   
    MonjoCursor<PojoWithListInnerObject> monjoCursor = monjoComplex.find();
    PojoWithListInnerObject complex = monjoCursor.toList().get(0);
    assertNotNull(complex.getCategories().get(0).getId());
  }
View Full Code Here

Examples of org.monjo.example.PojoWithListInnerObject

    assertNotNull(complex.getCategories().get(0).getId());
  }

  @Test
  public void shouldAddNewCategory() throws Exception {
    PojoWithListInnerObject pojo = PojoBuilder.createMegaZordePojo();
    Monjo<ObjectId, PojoWithListInnerObject> monjoComplex = new Monjo<ObjectId, PojoWithListInnerObject>(getMongoDB(),
        PojoWithListInnerObject.class);
    monjoComplex.removeAll();
   
    monjoComplex.insert(pojo);
    Category otherCategory = new Category();
    otherCategory.setName("Other Category");
    pojo.addCategory(otherCategory);
   
    monjoComplex.update(pojo);   
    MonjoCursor<PojoWithListInnerObject> monjoCursor = monjoComplex.find();
    PojoWithListInnerObject complex = monjoCursor.toList().get(0);
    assertEquals(2, complex.getCategories().size());
  }
View Full Code Here

Examples of org.monjo.example.PojoWithListInnerObject

    assertEquals(2, complex.getCategories().size());
  }

  @Test
  public void shouldAddNewCategoryButIHaveOnlyAnId() throws Exception {
    PojoWithListInnerObject pojo = PojoBuilder.createMegaZordePojo();
    Monjo<ObjectId, PojoWithListInnerObject> monjoComplex = new Monjo<ObjectId, PojoWithListInnerObject>(getMongoDB(),
        PojoWithListInnerObject.class);
    monjoComplex.removeAll();
   
    monjoComplex.insert(pojo);
   
    PojoWithListInnerObject anotherPojo  = new PojoWithListInnerObject();
    anotherPojo.setId(pojo.getId());
    Category otherCategory = new Category();
    otherCategory.setName("Other Category");
    anotherPojo.addCategory(otherCategory);
   
    monjoComplex.updateWithAddSet(anotherPojo);
   
    MonjoCursor<PojoWithListInnerObject> monjoCursor = monjoComplex.find();
    PojoWithListInnerObject complex = monjoCursor.toList().get(0);
    assertEquals(2, complex.getCategories().size());
  }
View Full Code Here

Examples of org.monjo.example.PojoWithListInnerObject

    assertTrue(extraInfo.equals(classPojo.getExtraProperty()));
  }

  @Test
  public void shouldNotLoseFields() throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {
    PojoWithListInnerObject innerObject = PojoBuilder.createMegaZordePojo();
    Category inicialCategory = innerObject.getCategories().get(0);
    innerObject.getCategories().get(0).setWeight(100l);
    Monjo<ObjectId, PojoWithListInnerObject> monjo = new Monjo<ObjectId, PojoWithListInnerObject>(getMongoDB(), PojoWithListInnerObject.class);
    monjo.insert(innerObject);
   
    PojoWithListInnerObject anotherObject = new PojoWithListInnerObject();
    Category category   = new Category();
    category.setWeight(200l);
    category.setId(inicialCategory.getId());
    anotherObject.addCategory(category);
   
    monjo.updateInnerObject(anotherObject, "categories");
   
    PojoWithListInnerObject result = monjo.findOne(innerObject.getId());
    Category categoryResult = result.getCategories().get(0);
    assertEquals(inicialCategory.getName(), categoryResult.getName());
    assertEquals(category.getWeight(), categoryResult.getWeight());
  }
View Full Code Here

Examples of org.monjo.example.PojoWithListInnerObject

    ConvertUtils.register(new StatusConverter(), Status.class);
  }

  @Test
  public void shouldFindByExample() {
    PojoWithListInnerObject createMegaZordePojo = PojoBuilder.createMegaZordePojo();
    Monjo<ObjectId, PojoWithListInnerObject> monjo = new Monjo<ObjectId, PojoWithListInnerObject>(getMongoDB(), PojoWithListInnerObject.class);
    monjo.removeAll();
    monjo.insert(createMegaZordePojo);
   
    PojoWithListInnerObject createMegaZordePojo2 = new PojoWithListInnerObject();
    createMegaZordePojo2.addCategory(createMegaZordePojo.getCategories().get(0));
    PojoWithListInnerObject result = monjo.findByExample(createMegaZordePojo).toList().get(0);
    assertNotNull(result.getCategories().get(0).getId());
  }
View Full Code Here

Examples of org.monjo.example.PojoWithListInnerObject

    assertNotNull(result.getCategories().get(0).getId());
  }

  @Test
  public void shouldFindByExampleSoSo() {
    PojoWithListInnerObject createMegaZordePojo = PojoBuilder.createMegaZordePojo();
    Monjo<ObjectId, PojoWithListInnerObject> monjo = new Monjo<ObjectId, PojoWithListInnerObject>(getMongoDB(), PojoWithListInnerObject.class);
    monjo.removeAll();
    monjo.insert(createMegaZordePojo);

    List<Category> categories = createMegaZordePojo.getCategories();

    createMegaZordePojo = new PojoWithListInnerObject();
    Category findCategory = new Category();
    findCategory.setId(categories.get(0).getId());
    createMegaZordePojo.addCategory(findCategory);

   
    PojoWithListInnerObject result = monjo.findByExample(createMegaZordePojo).toList().get(0);
    assertNotNull(result.getCategories().get(0).getId());
  }
View Full Code Here

Examples of org.monjo.example.PojoWithListInnerObject

    assertNotNull(result.getCategories().get(0).getId());
  }

  @Test
  public void shouldFindByExampleSoSoWithProxy() {
    PojoWithListInnerObject createMegaZordePojo = PojoBuilder.createMegaZordePojo();
    Monjo<ObjectId, PojoWithListInnerObject> monjo = new Monjo<ObjectId, PojoWithListInnerObject>(getMongoDB(), PojoWithListInnerObject.class);
    monjo.removeAll();
    monjo.insert(createMegaZordePojo);
   
    List<Category> categories = createMegaZordePojo.getCategories();
    createMegaZordePojo = new PojoWithListInnerObject();
    Category findCategory = new Category();
    findCategory.setId(categories.get(0).getId());
    List<Category> list = new ArrayList<Category>();
    list.add(findCategory);
   
    PojoWithListInnerObject megaZordProxified = DirtWatcherProxifier.proxify(new PojoWithListInnerObject());
    megaZordProxified.setCategories(list);
    PojoWithListInnerObject result = monjo.findByExample(megaZordProxified).toList().get(0);
    assertNotNull(result.getCategories().get(0).getId());
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.