@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")); }
@Test public void testEntitySetsQuery() { final SimpleEntity e1 = 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); } }, "Id"); Assert.assertEquals(1, c.getEntitySets().count()); Assert.assertEquals("entitySetName", c.getEntitySets().first().getTitle()); Assert.assertEquals("entitySetName", c.getEntitySets().first().getHref()); }