use of com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.complex.model.CreatableLegacyOrderPositionElementView in project blaze-persistence by Blazebit.
the class EntityViewUpdateSubviewInverseEmbeddedComplexTest method testAddElementCreateViewToCollection.
@Test
public void testAddElementCreateViewToCollection() {
// Given
UpdatableLegacyOrderView newOrder = evm.create(UpdatableLegacyOrderView.class);
CreatableLegacyOrderPositionView position = evm.create(CreatableLegacyOrderPositionView.class);
position.getId().setPositionId(0);
position.setArticleNumber("123");
newOrder.getPositions().add(position);
update(newOrder);
// When
CreatableLegacyOrderPositionElementView elementView = evm.create(CreatableLegacyOrderPositionElementView.class);
elementView.setText("test");
newOrder.getPositions().iterator().next().getElems().add(elementView);
update(newOrder);
// Then
em.clear();
LegacyOrder legacyOrder = em.find(LegacyOrder.class, newOrder.getId());
Assert.assertEquals(1, legacyOrder.getPositions().size());
LegacyOrderPosition orderPosition = legacyOrder.getPositions().iterator().next();
Assert.assertEquals(new LegacyOrderPositionId(newOrder.getId(), 0), orderPosition.getId());
Assert.assertEquals(1, orderPosition.getElems().size());
Assert.assertEquals("test", orderPosition.getElems().iterator().next().getText());
}
Aggregations