use of com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.simple.model.LegacyOrderPositionIdView in project blaze-persistence by Blazebit.
the class EntityViewUpdateSubviewInverseEmbeddedSimpleTest method testPersistAndAddNewElementToNewCollection.
@Test
public void testPersistAndAddNewElementToNewCollection() {
// When
UpdatableLegacyOrderView newOrder = evm.create(UpdatableLegacyOrderView.class);
UpdatableLegacyOrderPositionView position = evm.create(UpdatableLegacyOrderPositionView.class);
position.getId().setPositionId(0);
position.setArticleNumber("123");
newOrder.setPositions(new HashSet<>(Arrays.<LegacyOrderPositionIdView>asList(position)));
update(newOrder);
// Then
// After update, the position is replaced with the declaration type
assertFalse(newOrder.getPositions().iterator().next() instanceof UpdatableLegacyOrderPositionView);
em.clear();
LegacyOrder legacyOrder = em.find(LegacyOrder.class, newOrder.getId());
Assert.assertEquals(1, legacyOrder.getPositions().size());
Assert.assertEquals(new LegacyOrderPositionId(newOrder.getId(), 0), legacyOrder.getPositions().iterator().next().getId());
}
Aggregations