Beispiel #1
0
  @Test
  public void testDelete() throws Exception {
    final CompoundIdEntity entity = new CompoundIdEntity();
    entity.id = new CompoundId("test");

    getDs().save(entity);
    getDs().delete(CompoundIdEntity.class, entity.id);
  }
Beispiel #2
0
  @Test
  @Ignore("https://github.com/mongodb/morphia/issues/675")
  public void testReference() {
    getMorphia().map(CompoundIdEntity.class, CompoundId.class);
    getDs().getCollection(CompoundIdEntity.class).drop();

    final CompoundIdEntity sibling = new CompoundIdEntity();
    sibling.id = new CompoundId("sibling ID");
    getDs().save(sibling);

    final CompoundIdEntity entity = new CompoundIdEntity();
    entity.id = new CompoundId("entity ID");
    entity.e = "some value";
    entity.sibling = sibling;
    getDs().save(entity);

    final CompoundIdEntity loaded = getDs().get(entity);
    Assert.assertEquals(entity, loaded);
  }
Beispiel #3
0
  @Test
  public void testMapping() throws Exception {
    CompoundIdEntity entity = new CompoundIdEntity();
    entity.id = new CompoundId("test");

    getDs().save(entity);
    entity = getDs().get(entity);
    Assert.assertEquals("test", entity.id.name);
    Assert.assertNotNull(entity.id.id);
  }
Beispiel #4
0
  @Test
  public void testOtherDelete() throws Exception {
    final CompoundIdEntity entity = new CompoundIdEntity();
    entity.id = new CompoundId("test");

    getDs().save(entity);
    ((AdvancedDatastore) getDs())
        .delete(
            getDs().getCollection(CompoundIdEntity.class).getName(),
            CompoundIdEntity.class,
            entity.id);
  }