@Test
  public void testSimpleEntity() {

    final SimpleEntity e1 = new SimpleEntity();
    final SimpleEntity e2 = new SimpleEntity();
    final SimpleEntity e3 = new SimpleEntity();

    String namespace = "testSetNameAndType";
    InMemoryProducer p = new InMemoryProducer(namespace);
    ODataConsumer c = new ODataConsumerAdapter(p);

    p.register(
        SimpleEntity.class,
        "entitySetName",
        "entityTypeName",
        new Func<Iterable<SimpleEntity>>() {
          @Override
          public Iterable<SimpleEntity> apply() {
            return Enumerable.create(e1, e2, e3);
          }
        },
        "Id");

    Assert.assertEquals(3, c.getEntities("entitySetName").execute().count());
    Assert.assertNotNull(c.getEntity("entitySetName", OEntityKey.create(e1.getId())).execute());

    Assert.assertNotNull(p.getMetadata().findEdmEntitySet("entitySetName"));
    Assert.assertNotNull(p.getMetadata().findEdmEntityType(namespace + ".entityTypeName"));
  }
 private static Map<String, SimpleEntity> collectionToMap(Collection<SimpleEntity> entities) {
   Map<String, SimpleEntity> map = Maps.newHashMap();
   for (SimpleEntity entity : entities) {
     map.put(entity.getId(), entity);
   }
   return map;
 }
예제 #3
0
  @Test
  public void testMultiLoadWithCacheModeIgnore() {
    // do the multi-load, telling Hibernate to IGNORE the L2 cache -
    //		the end result should be that the cache is (still) empty afterwards
    Session session = openSession();
    session.getTransaction().begin();
    List<SimpleEntity> list =
        session.byMultipleIds(SimpleEntity.class).with(CacheMode.IGNORE).multiLoad(ids(56));
    session.getTransaction().commit();
    session.close();

    assertEquals(56, list.size());
    for (SimpleEntity entity : list) {
      assertFalse(sessionFactory().getCache().containsEntity(SimpleEntity.class, entity.getId()));
    }
  }