Search in sources :

Example 1 with CreatableLegacyOrderPositionElementView

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());
}
Also used : CreatableLegacyOrderPositionView(com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.complex.model.CreatableLegacyOrderPositionView) LegacyOrderPosition(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPosition) LegacyOrderPositionId(com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionId) CreatableLegacyOrderPositionElementView(com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.complex.model.CreatableLegacyOrderPositionElementView) LegacyOrder(com.blazebit.persistence.view.testsuite.entity.LegacyOrder) UpdatableLegacyOrderView(com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.complex.model.UpdatableLegacyOrderView) AbstractEntityViewUpdateTest(com.blazebit.persistence.view.testsuite.update.AbstractEntityViewUpdateTest) Test(org.junit.Test)

Aggregations

LegacyOrder (com.blazebit.persistence.view.testsuite.entity.LegacyOrder)1 LegacyOrderPosition (com.blazebit.persistence.view.testsuite.entity.LegacyOrderPosition)1 LegacyOrderPositionId (com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionId)1 AbstractEntityViewUpdateTest (com.blazebit.persistence.view.testsuite.update.AbstractEntityViewUpdateTest)1 CreatableLegacyOrderPositionElementView (com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.complex.model.CreatableLegacyOrderPositionElementView)1 CreatableLegacyOrderPositionView (com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.complex.model.CreatableLegacyOrderPositionView)1 UpdatableLegacyOrderView (com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.complex.model.UpdatableLegacyOrderView)1 Test (org.junit.Test)1