Search in sources :

Example 21 with EntityOpResult

use of com.qcadoo.model.api.EntityOpResult in project qcadoo by qcadoo.

the class ManyToManyIntegrationTest method shouldPerformCascadeDeletion.

@Test
public final void shouldPerformCascadeDeletion() {
    // given
    Entity firstProduct = save(createProduct("asd", "00001"));
    Entity secondProduct = save(createProduct("fgh", "00002"));
    Entity thirdProduct = save(createProduct("jkl", "00003"));
    Entity anotherProduct = save(createProduct("qwertyuiop", "00004"));
    Entity firstPart = save(createPart("qwe", anotherProduct, Lists.newArrayList(firstProduct, secondProduct)));
    Entity secondPart = save(createPart("rty", anotherProduct, Lists.newArrayList(firstProduct, thirdProduct)));
    Entity thirdPart = save(createPart("uiop", anotherProduct, Lists.newArrayList(firstProduct, secondProduct, thirdProduct)));
    // when
    EntityOpResult result = delete(secondProduct);
    // then
    Assert.assertTrue(result.isSuccessfull());
    Assert.assertNull(fromDb(firstPart));
    Assert.assertNotNull(fromDb(secondPart));
    Assert.assertNull(fromDb(thirdPart));
    Assert.assertNotNull(fromDb(firstProduct));
    Assert.assertNull(fromDb(secondProduct));
    Assert.assertNotNull(fromDb(thirdProduct));
}
Also used : Entity(com.qcadoo.model.api.Entity) ProxyEntity(com.qcadoo.model.internal.ProxyEntity) EntityOpResult(com.qcadoo.model.api.EntityOpResult) Test(org.junit.Test)

Aggregations

EntityOpResult (com.qcadoo.model.api.EntityOpResult)21 Entity (com.qcadoo.model.api.Entity)19 Test (org.junit.Test)15 ProxyEntity (com.qcadoo.model.internal.ProxyEntity)4 FieldDefinition (com.qcadoo.model.api.FieldDefinition)2 ErrorMessage (com.qcadoo.model.api.validators.ErrorMessage)2 InternalDataDefinition (com.qcadoo.model.internal.api.InternalDataDefinition)2 InternalFieldDefinition (com.qcadoo.model.internal.api.InternalFieldDefinition)2 ArrayList (java.util.ArrayList)2 EntityList (com.qcadoo.model.api.EntityList)1 EntityMessagesHolder (com.qcadoo.model.api.EntityMessagesHolder)1 Monitorable (com.qcadoo.model.api.aop.Monitorable)1 CollectionFieldType (com.qcadoo.model.api.types.CollectionFieldType)1 HasManyType (com.qcadoo.model.api.types.HasManyType)1 TreeType (com.qcadoo.model.api.types.TreeType)1 EntitySignature (com.qcadoo.model.internal.utils.EntitySignature)1 GridComponent (com.qcadoo.view.api.components.GridComponent)1 AbstractStateTest (com.qcadoo.view.internal.states.AbstractStateTest)1 Collection (java.util.Collection)1 List (java.util.List)1