Search in sources :

Example 1 with SoftDelete_Project

use of com.haulmont.cuba.core.model.SoftDelete_Project in project jmix by jmix-framework.

the class SoftDeleteNotFoundDeletedTest method setUp.

@BeforeEach
public void setUp() throws Exception {
    Transaction tx = persistence.createTransaction();
    try {
        EntityManager em = persistence.getEntityManager();
        SoftDelete_Service service = new SoftDelete_Service();
        serviceId = service.getId();
        service.setName("service");
        service.setCode("serviceCode");
        em.persist(service);
        SoftDelete_Task task = new SoftDelete_Task();
        taskId = task.getId();
        task.setMessage("message");
        task.setService(service);
        em.persist(task);
        SoftDelete_TaskValue taskValue = new SoftDelete_TaskValue();
        taskValueId = taskValue.getId();
        taskValue.setTask(task);
        em.persist(taskValue);
        SoftDelete_Project project = new SoftDelete_Project();
        projectId = project.getId();
        project.setName("project");
        project.setAValue(taskValue);
        project.setTask(task);
        em.persist(project);
        tx.commitRetaining();
        em = persistence.getEntityManager();
        task = em.find(SoftDelete_Task.class, taskId);
        em.remove(task);
        tx.commit();
    } finally {
        tx.end();
    }
}
Also used : SoftDelete_Task(com.haulmont.cuba.core.model.SoftDelete_Task) SoftDelete_Service(com.haulmont.cuba.core.model.SoftDelete_Service) SoftDelete_TaskValue(com.haulmont.cuba.core.model.SoftDelete_TaskValue) SoftDelete_Project(com.haulmont.cuba.core.model.SoftDelete_Project) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with SoftDelete_Project

use of com.haulmont.cuba.core.model.SoftDelete_Project in project jmix by jmix-framework.

the class SoftDeleteNotFoundDeletedTest method testLoadDeletedObject.

@Test
public void testLoadDeletedObject() {
    FetchPlan taskView_Message = new View(SoftDelete_Task.class).addProperty("message");
    FetchPlan taskView_Service = new View(SoftDelete_Task.class).addProperty("service", new View(SoftDelete_Service.class).addProperty("code"));
    FetchPlan taskValueView = new View(SoftDelete_TaskValue.class).addProperty("task", taskView_Message);
    FetchPlan projectView = new View(SoftDelete_Project.class).addProperty("name").addProperty("aValue", taskValueView).addProperty("task", taskView_Service);
    LoadContext<SoftDelete_Project> loadContext = new LoadContext<>(SoftDelete_Project.class).setView(projectView).setId(projectId);
    SoftDelete_Project project = dataManager.load(loadContext);
    Assertions.assertNotNull(project);
    Assertions.assertNotNull(project.getTask());
    Assertions.assertTrue(project.getTask().isDeleted());
}
Also used : SoftDelete_Task(com.haulmont.cuba.core.model.SoftDelete_Task) SoftDelete_TaskValue(com.haulmont.cuba.core.model.SoftDelete_TaskValue) LoadContext(com.haulmont.cuba.core.global.LoadContext) SoftDelete_Project(com.haulmont.cuba.core.model.SoftDelete_Project) FetchPlan(io.jmix.core.FetchPlan) View(com.haulmont.cuba.core.global.View) CoreTest(com.haulmont.cuba.core.testsupport.CoreTest) Test(org.junit.jupiter.api.Test)

Aggregations

SoftDelete_Project (com.haulmont.cuba.core.model.SoftDelete_Project)2 SoftDelete_Task (com.haulmont.cuba.core.model.SoftDelete_Task)2 SoftDelete_TaskValue (com.haulmont.cuba.core.model.SoftDelete_TaskValue)2 LoadContext (com.haulmont.cuba.core.global.LoadContext)1 View (com.haulmont.cuba.core.global.View)1 SoftDelete_Service (com.haulmont.cuba.core.model.SoftDelete_Service)1 CoreTest (com.haulmont.cuba.core.testsupport.CoreTest)1 FetchPlan (io.jmix.core.FetchPlan)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1