Search in sources :

Example 1 with LegacyOrderPositionIdView

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

Aggregations

LegacyOrder (com.blazebit.persistence.view.testsuite.entity.LegacyOrder)1 LegacyOrderPositionId (com.blazebit.persistence.view.testsuite.entity.LegacyOrderPositionId)1 AbstractEntityViewUpdateTest (com.blazebit.persistence.view.testsuite.update.AbstractEntityViewUpdateTest)1 LegacyOrderPositionIdView (com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.simple.model.LegacyOrderPositionIdView)1 UpdatableLegacyOrderPositionView (com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.simple.model.UpdatableLegacyOrderPositionView)1 UpdatableLegacyOrderView (com.blazebit.persistence.view.testsuite.update.subview.inverse.embedded.simple.model.UpdatableLegacyOrderView)1 Test (org.junit.Test)1