use of com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.complex.model.UpdatableLegacyOrderPositionView in project blaze-persistence by Blazebit.
the class EntityViewUpdateSubviewInverseEmbeddedComplexTest method testRemoveReadOnlyElementFromCollection.
@Test
public void testRemoveReadOnlyElementFromCollection() {
// Given
UpdatableLegacyOrderView newOrder = evm.create(UpdatableLegacyOrderView.class);
UpdatableLegacyOrderPositionView position = evm.create(UpdatableLegacyOrderPositionView.class);
position.getId().setPositionId(0);
position.setArticleNumber("123");
newOrder.getPositions().add(position);
update(newOrder);
// When
em.clear();
newOrder = evm.applySetting(EntityViewSetting.create(UpdatableLegacyOrderView.class), cbf.create(em, LegacyOrder.class)).getSingleResult();
newOrder.getPositions().remove(newOrder.getPositions().iterator().next());
PluralChangeModel<Object, Object> positionsChangeModel = (PluralChangeModel<Object, Object>) evm.getChangeModel(newOrder).get("positions");
Assert.assertEquals(1, positionsChangeModel.getRemovedElements().size());
update(newOrder);
// Then
em.clear();
LegacyOrder legacyOrder = em.find(LegacyOrder.class, newOrder.getId());
Assert.assertEquals(0, legacyOrder.getPositions().size());
}
use of com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.complex.model.UpdatableLegacyOrderPositionView in project blaze-persistence by Blazebit.
the class EntityViewUpdateSubviewInverseEmbeddedComplexTest method testRemoveById.
// Test for https://github.com/Blazebit/blaze-persistence/issues/1299
@Test
public void testRemoveById() {
// Given
UpdatableLegacyOrderView newOrder = evm.create(UpdatableLegacyOrderView.class);
UpdatableLegacyOrderPositionView position = evm.create(UpdatableLegacyOrderPositionView.class);
position.getId().setPositionId(0);
position.setArticleNumber("123");
newOrder.getPositions().add(position);
update(newOrder);
// When
em.clear();
evm.remove(em, UpdatableLegacyOrderView.class, newOrder.getId());
em.flush();
em.clear();
// Then
LegacyOrder legacyOrder = em.find(LegacyOrder.class, newOrder.getId());
Assert.assertNull(legacyOrder);
}
Aggregations