Package org.monjo.example

Examples of org.monjo.example.Category


    another.setDescription("pojo complexo");
    return another;
  }

  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);
View Full Code Here


  }

  @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

    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);
View Full Code Here

   
    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();
View Full Code Here

 
 
  @Test
  public void shouldUseRef() throws Exception{
   
    Category category = new Category();
    category.setName("NewCategory");
    Monjo<ObjectId, Category> monjoCategory = new Monjo<ObjectId, Category>(getMongoDB(), Category.class);
    monjoCategory.insert(category);

    ComplexPojo complexPojo = PojoBuilder.createComplexPojo(category);
//    complexPojo.setCategories(categories);
    Monjo<ObjectId, ComplexPojo> monjoComplex = new Monjo<ObjectId, ComplexPojo>(getMongoDB(), ComplexPojo.class);

    monjoComplex.removeAll();
    monjoCategory.removeAll();

    monjoComplex.insert(complexPojo);
   
    MonjoCursor<ComplexPojo> monjoCursor = monjoComplex.find();
    ComplexPojo complex = monjoCursor.toList().get(0);
    assertEquals(category.getId(), complex.getCategory().getId());
  //  assertEquals(category.getId(), complex.getCategories().get(0).getId());
   
  }
View Full Code Here

    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

    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);
View Full Code Here

TOP

Related Classes of org.monjo.example.Category

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.