Search in sources :

Example 6 with Server

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

the class TransactionTest method testSuspend.

@Test
public void testSuspend() {
    Transaction tx = persistence.getTransaction();
    try {
        EntityManager em = persistence.getEntityManager();
        Server server = new Server();
        server.setName("localhost");
        server.setRunning(true);
        em.persist(server);
        Transaction tx1 = persistence.createTransaction();
        try {
            EntityManager em1 = persistence.getEntityManager();
            assertTrue(em != em1);
            Query query = em1.createQuery("select s from test$Server s");
            List list = query.getResultList();
            assertNotNull(list);
            tx1.commit();
        } finally {
            tx1.end();
        }
        tx.commit();
    } finally {
        tx.end();
    }
}
Also used : Server(com.haulmont.cuba.core.model.common.Server) List(java.util.List) CoreTest(com.haulmont.cuba.core.testsupport.CoreTest) Test(org.junit.jupiter.api.Test)

Example 7 with Server

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

the class TransactionTest method __testCommitRetainingAndRollback.

private void __testCommitRetainingAndRollback() {
    UUID id;
    Transaction tx = persistence.createTransaction();
    try {
        EntityManager em = persistence.getEntityManager();
        assertNotNull(em);
        Server server = new Server();
        id = server.getId();
        server.setName("localhost");
        server.setRunning(true);
        em.persist(server);
        tx.commitRetaining();
        em = persistence.getEntityManager();
        server = em.find(Server.class, id);
        assertEquals(id, server.getId());
        server.setRunning(false);
        throwException();
        tx.commit();
    } finally {
        tx.end();
    }
}
Also used : Server(com.haulmont.cuba.core.model.common.Server) UUID(java.util.UUID)

Example 8 with Server

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

the class NamePatternTest method test.

@Test
public void test() {
    Server server = new Server();
    server.setName("orion");
    server.setRunning(false);
    assertEquals("orion", metadataTools.getInstanceName(server));
}
Also used : Server(com.haulmont.cuba.core.model.common.Server) CoreTest(com.haulmont.cuba.core.testsupport.CoreTest) Test(org.junit.jupiter.api.Test)

Example 9 with Server

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

the class DataManagerTest method testLoadListCaseInsensitiveLower.

@Test
public void testLoadListCaseInsensitiveLower() {
    Server server = new Server();
    server.setName("LocalHost");
    server.setRunning(true);
    DataManager dataManager = AppBeans.get(DataManager.NAME);
    dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
    LoadContext<Server> loadContext = LoadContext.create(Server.class);
    loadContext.setQueryString("select s from test$Server s where s.name like :name").setParameter("name", "(?i)%localhost%");
    List<Server> list = dataManager.loadList(loadContext);
    assertTrue(list.size() > 0);
}
Also used : Entity(io.jmix.core.Entity) Server(com.haulmont.cuba.core.model.common.Server) CommitContext(com.haulmont.cuba.core.global.CommitContext) DataManager(com.haulmont.cuba.core.global.DataManager) CoreTest(com.haulmont.cuba.core.testsupport.CoreTest) Test(org.junit.jupiter.api.Test)

Example 10 with Server

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

the class DataManagerTest method testLoadList.

@Test
public void testLoadList() {
    Server server = new Server();
    server.setName("localhost");
    server.setRunning(true);
    dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
    LoadContext<Server> loadContext = LoadContext.create(Server.class);
    loadContext.setQueryString("select s from " + metadata.getClass(Server.class).getName() + " s");
    List<Server> list = dataManager.loadList(loadContext);
    assertTrue(list.size() > 0);
}
Also used : Entity(io.jmix.core.Entity) Server(com.haulmont.cuba.core.model.common.Server) CommitContext(com.haulmont.cuba.core.global.CommitContext) CoreTest(com.haulmont.cuba.core.testsupport.CoreTest) Test(org.junit.jupiter.api.Test)

Aggregations

Server (com.haulmont.cuba.core.model.common.Server)27 CoreTest (com.haulmont.cuba.core.testsupport.CoreTest)24 Test (org.junit.jupiter.api.Test)24 UUID (java.util.UUID)10 CommitContext (com.haulmont.cuba.core.global.CommitContext)8 Entity (io.jmix.core.Entity)8 DataManager (com.haulmont.cuba.core.global.DataManager)2 LoadContext (com.haulmont.cuba.core.global.LoadContext)2 View (com.haulmont.cuba.core.global.View)2 User (com.haulmont.cuba.core.model.common.User)2 FetchPlan (io.jmix.core.FetchPlan)2 Date (java.util.Date)2 AppBeans (com.haulmont.cuba.core.global.AppBeans)1 Metadata (com.haulmont.cuba.core.global.Metadata)1 CascadeDeletionPolicyEntity (com.haulmont.cuba.core.model.CascadeDeletionPolicyEntity)1 EntityDiff (com.haulmont.cuba.core.model.common.EntityDiff)1 FileDescriptor (com.haulmont.cuba.core.model.common.FileDescriptor)1 Group (com.haulmont.cuba.core.model.common.Group)1 Customer (com.haulmont.cuba.core.model.sales.Customer)1 Order (com.haulmont.cuba.core.model.sales.Order)1