Examples of SimplePOJO


Examples of org.monjo.example.SimplePOJO

    document.put("aFloatField", 45.0f);
    saveToMongo(document);

    DBObject docFromMongo = getFromMongo(document.get("_id"));
    DocumentToObjectConverter<SimplePOJO> converter = MonjoConverterFactory.getInstance().getDefaultDocumentConverter(SimplePOJO.class);
    SimplePOJO convertedObject = converter.from(docFromMongo).to();
    assertThat(convertedObject.getAnIntegerField(), is(equalTo(42)));
    assertThat(convertedObject.getaLongField(), is(equalTo(43L)));
    assertThat(convertedObject.getaDoubleField(), is(equalTo(44.0)));
  }
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    saveToMongo(document);

    DBObject docFromMongo = getFromMongo(document.get("_id"));
    DocumentToObjectConverter<SimplePOJO> converter = MonjoConverterFactory.getInstance().getDefaultDocumentConverter(SimplePOJO.class);
   
    SimplePOJO convertedObject = converter.from(docFromMongo).to();
    assertThat(convertedObject.getaMapField(), is(equalTo(map)));
  }
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    Object documentId = document.get("_id");
    DBObject docFromMongo = getFromMongo(documentId);

    DocumentToObjectConverter<SimplePOJO> converter = MonjoConverterFactory.getInstance().getDefaultDocumentConverter(SimplePOJO.class);
 
    SimplePOJO convertedObject = converter.from(docFromMongo).to();
    assertThat(convertedObject.getId(), is(equalTo(documentId)));
  }
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    saveToMongo(document);

    DBObject docFromMongo = getFromMongo(document.get("_id"));
    DocumentToObjectConverter<SimplePOJO> converter = MonjoConverterFactory.getInstance().getDefaultDocumentConverter(SimplePOJO.class);

    SimplePOJO simplePOJO = converter.from(docFromMongo).to();
    assertThat(simplePOJO.getaTransientField(), is(nullValue()));
  }
View Full Code Here

Examples of org.monjo.example.SimplePOJO

  }
 
  @Test
  @SuppressWarnings("rawtypes")
  public void shouldConvertASimpleDocumentWithStringFieldsToAJavaObject() {
    SimplePOJO pojo = new SimplePOJO();
    pojo.setaField("foo");
    pojo.setAnotherField("bar");
   
    DBObject document = converter.from(pojo).toDocument();
   
    assertThat(document.containsField("a_field"), is(true));
    Class a_fieldClass = document.get("a_field").getClass();
View Full Code Here

Examples of org.monjo.example.SimplePOJO

  }
 
  @Test
  @SuppressWarnings("rawtypes")
  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("an_integer_field").getClass();
    assertThat(anIntegerFieldClass, classEqualTo(Integer.class));
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    assertThat((Double) document.get("a_double_field"), is(equalTo(44.0)));
  }

  @Test
  public void shouldOnlyPopulateFieldsThatAreNotNull() {
    SimplePOJO pojo = new SimplePOJO();
    pojo.setAnIntegerField(42);
   
    DBObject document = converter.from(pojo).toDocument();
   
    assertThat(document.containsField("an_integer_field"), is(true));
    assertThat(document.containsField("_id"), is(true));
View Full Code Here

Examples of org.monjo.example.SimplePOJO

public class DirtyWatcherAspectTest {
 
 
  @Test
  public void shouldVerifyFieldCalling(){
    SimplePOJO simplePOJO = new SimplePOJO();
    simplePOJO.setaDoubleField(10.0);
    DirtFieldsWatcher monjoObject = (DirtFieldsWatcher) simplePOJO;
    Set<String> dirtFields = monjoObject.dirtFields();
    assertEquals(1, dirtFields.size());
    assertThat(dirtFields, hasItems("setaDoubleField"));
  }
View Full Code Here

Examples of org.monjo.example.SimplePOJO

import org.monjo.example.User;

public class PojoBuilder {

  public static SimplePOJO createSimplePojo() {
    SimplePOJO pojo = new SimplePOJO();
    pojo.setAnIntegerField(42);
    pojo.setaLongField(43L);
    pojo.setaDoubleField(44.0);
    return pojo;
  }
View Full Code Here

Examples of org.monjo.example.SimplePOJO

    assertEquals(5, list.size());
  }

  private void insertPojoCollection(Monjo<ObjectId, SimplePOJO> monjo) {
    for (int i = 0; i < 30; i++) {
      SimplePOJO pojo = new SimplePOJO();
      pojo.setAnIntegerField(i);
      pojo.setaLongField(43L);
      pojo.setaDoubleField(44.0);

      monjo.insert(pojo);
    }
  }
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.