@Test public void testLoadingOfRefThroughInheritanceInField() throws Exception { // TODO us: exclusion does not work properly with maven + junit4 if (!LazyFeatureDependencies.testDependencyFullFilled()) { return; } morphia.map(ContainerWithRefInField.class); morphia.map(OtherEntityChild.class); OtherEntityChild otherEntity = new OtherEntityChild(); ContainerWithRefInField containerWithRefInField = new ContainerWithRefInField(); ds.save(otherEntity, containerWithRefInField); otherEntity = ds.get(otherEntity); final ContainerWithRefInField reload = ds.get(containerWithRefInField); Assert.assertNotNull(otherEntity); Assert.assertNotNull(reload); EmbedWithRef embedWithRef = new EmbedWithRef(); embedWithRef.otherEntity = otherEntity; reload.embedWithRef = embedWithRef; ds.save(reload); ds.get(reload); containerWithRefInField = ds.get(containerWithRefInField); Assert.assertNotNull(containerWithRefInField); }
@Test public void testLoadingOfRefInList() throws Exception { // TODO us: exclusion does not work properly with maven + junit4 if (!LazyFeatureDependencies.testDependencyFullFilled()) { return; } morphia.map(ContainerWithRefList.class); morphia.map(OtherEntity.class); OtherEntity otherEntity = new OtherEntity(); ContainerWithRefList containerWithRefInList = new ContainerWithRefList(); ds.save(otherEntity, containerWithRefInList); otherEntity = ds.get(otherEntity); containerWithRefInList = ds.get(containerWithRefInList); Assert.assertNotNull(otherEntity); Assert.assertNotNull(containerWithRefInList); EmbedWithRef embedWithRef = new EmbedWithRef(); embedWithRef.otherEntity = otherEntity; containerWithRefInList.embedWithRef.add(embedWithRef); ds.save(otherEntity, containerWithRefInList); containerWithRefInList = ds.get(containerWithRefInList); Assert.assertNotNull(containerWithRefInList); Query<ContainerWithRefList> createQuery = ds.createQuery(ContainerWithRefList.class); containerWithRefInList = createQuery.get(); Assert.assertNotNull(containerWithRefInList); }
@Test @Ignore public final void testCreateProxy() { // TODO us: exclusion does not work properly with maven + junit4 if (!LazyFeatureDependencies.testDependencyFullFilled()) { return; } final E e = new E(); e.setFoo("bar"); final Key<E> key = getDs().save(e); E eProxy = new CGLibLazyProxyFactory().createProxy(getDs(), E.class, key); assertNotFetched(eProxy); Assert.assertEquals("bar", eProxy.getFoo()); assertFetched(eProxy); eProxy = deserialize(eProxy); assertNotFetched(eProxy); Assert.assertEquals("bar", eProxy.getFoo()); assertFetched(eProxy); }