Examples of SimplePOJO


Examples of org.monjo.example.SimplePOJO

  }
 
 
  @Test
  public void shouldFindBySimpleExample() {
    SimplePOJO simplePOJO = PojoBuilder.createSimplePojo();
    Monjo<ObjectId, SimplePOJO> monjo = new Monjo<ObjectId, SimplePOJO>(getMongoDB(), SimplePOJO.class);
    monjo.removeAll();
    monjo.insert(simplePOJO);
    SimplePOJO result = monjo.findByExample(simplePOJO).toList().get(0);
    assertNotNull(result.getId());   
  }
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    converter.toDocument();
  }

  @Test
  public void shouldConvertASimpleDocumentWithStringFieldsToAJavaObject() {
    SimplePOJO pojo = new SimplePOJO();
    pojo.setaField("foo");
    pojo.setAnotherField("bar");

    DBObject document = converter.from(pojo).toDocument();

    assertThat(document.containsField("aField"), is(true));
    Class<?> aFieldClass = document.get("aField").getClass();
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    assertThat((String) document.get("anotherField"), is(equalTo("bar")));
  }

  @Test
  public void shouldConvertNumericValues() {
    SimplePOJO pojo = new SimplePOJO();
    pojo.setAnIntegerField(42);
    pojo.setaLongField(43L);
    pojo.setaDoubleField(44.0);

    DBObject document = converter.from(pojo).toDocument();
   
    Class<?> anIntegerFieldClass = document.get("anIntegerField").getClass();
    assertThat(anIntegerFieldClass, classEqualTo(Integer.class));
View Full Code Here

Examples of org.monjo.example.SimplePOJO

  }

  @Test
  @SuppressWarnings("rawtypes")
  public void shouldPopulateIdIfDefined() {
    SimplePOJO pojo = new SimplePOJO();
    pojo.generateId();
    ObjectId id = pojo.getId();

    DBObject document = converter.from(pojo).toDocument();

    assertThat(document.containsField("_id"), is(true));
    Class idFieldClass = document.get("_id").getClass();
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    assertThat((ObjectId) document.get("_id"), is(equalTo(id)));
  }

  @Test
  public void shouldOnlyPopulateFieldsThatAreNotNull() {
    SimplePOJO pojo = new SimplePOJO();
    pojo.setAnIntegerField(42);

    DBObject document = converter.from(pojo).toDocument();

    assertThat(document.containsField("anIntegerField"), is(true));
    assertThat(document.containsField("_id"), is(true));
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    assertGeneratedIfOfTypeObjectIdIsPreserved();
  }

  @SuppressWarnings("rawtypes")
  private void assertIfOfTypeObjectIdIsPreserved() {
    SimplePOJO pojo = new SimplePOJO();
    pojo.generateId();
    ObjectId id = pojo.getId();

    DBObject document = converter.from(pojo).toDocument();
    saveToMongo(document);

    DBObject docFromMongo = getFromMongo(id);
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    assertThat(idClass, classEqualTo(ObjectId.class));
  }

  @SuppressWarnings("rawtypes")
  private void assertGeneratedIfOfTypeObjectIdIsPreserved() {
    SimplePOJO pojo = new SimplePOJO();

    DBObject document = converter.from(pojo).toDocument();
    saveToMongo(document);

    DBObject docFromMongo = getFromMongo(document.get("_id"));
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    assertThat(idClass, classEqualTo(String.class));
  }

  @Test
  public void shouldNotPopulateTransientFields() {
    SimplePOJO pojoWithTransientField = new SimplePOJO();
    pojoWithTransientField.setaTransientField("do not use");

    DBObject document = converter.from(pojoWithTransientField).toDocument();

    assertThat(document.containsField("aTransientField"), is(false));
  }
View Full Code Here

Examples of org.nutz.dao.test.meta.SimplePOJO

  }

  @Test
  public void test_insert_readonly() {
    dao.create(SimplePOJO.class, true);
    SimplePOJO p = new SimplePOJO();
    p.setSex("火星");
    dao.insert(p);
    p.setSex("东方不败");
    dao.update(p);
  }
View Full Code Here

Examples of org.nutz.dao.test.meta.SimplePOJO

    }

    @Test
    public void test_insert_readonly() {
        dao.create(SimplePOJO.class, true);
        SimplePOJO p = new SimplePOJO();
        p.setSex("火星");
        dao.insert(p);
        p.setSex("东方不败");
        dao.update(p);
    }
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.