Search in sources :

Example 1 with Server

use of com.haulmont.cuba.core.entity.Server in project cuba by cuba-platform.

the class DataManagerTest method testLoadListById.

@Test
public void testLoadListById() {
    Server server = new Server();
    UUID id = server.getId();
    server.setName("localhost");
    server.setRunning(true);
    dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
    LoadContext<Server> loadContext = LoadContext.create(Server.class).setId(id);
    List<Server> list = dataManager.loadList(loadContext);
    assertTrue(list.size() == 1);
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Server(com.haulmont.cuba.core.entity.Server) Test(org.junit.Test)

Example 2 with Server

use of com.haulmont.cuba.core.entity.Server in project cuba by cuba-platform.

the class DataManagerTest method test.

@Test
public void test() {
    Server server = new Server();
    UUID id = server.getId();
    server.setName("localhost");
    server.setRunning(true);
    dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
    LoadContext<Server> loadContext = LoadContext.create(Server.class).setId(id);
    server = dataManager.load(loadContext);
    assertEquals("localhost", server.getName());
    server.setName("krivopustov");
    dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Server(com.haulmont.cuba.core.entity.Server) Test(org.junit.Test)

Example 3 with Server

use of com.haulmont.cuba.core.entity.Server in project cuba by cuba-platform.

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 sys$Server s where s.name like :name").setParameter("name", "(?i)%localhost%");
    List<Server> list = dataManager.loadList(loadContext);
    assertTrue(list.size() > 0);
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Server(com.haulmont.cuba.core.entity.Server) Test(org.junit.Test)

Example 4 with Server

use of com.haulmont.cuba.core.entity.Server in project cuba by cuba-platform.

the class DataManagerTest method testLoad.

@Test
public void testLoad() {
    Server server = new Server();
    UUID id = server.getId();
    server.setName("localhost");
    server.setRunning(true);
    dataManager.commit(new CommitContext(Collections.<Entity>singleton(server)));
    LoadContext<Server> loadContext = LoadContext.create(Server.class).setId(id);
    server = dataManager.load(loadContext);
    assertEquals("localhost", server.getName());
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Server(com.haulmont.cuba.core.entity.Server) Test(org.junit.Test)

Example 5 with Server

use of com.haulmont.cuba.core.entity.Server in project cuba by cuba-platform.

the class DataManagerTest method testDataManagerLoadOneRecord.

@Test
public void testDataManagerLoadOneRecord() {
    Server server1 = new Server();
    server1.setName("app1");
    server1.setRunning(false);
    Server server2 = new Server();
    server2.setName("app2");
    server2.setRunning(false);
    dataManager.commit(new CommitContext(server1, server2));
    LoadContext<Server> lc = new LoadContext<>(Server.class);
    lc.setQueryString("select s from sys$Server s order by s.name").setMaxResults(1);
    Server latest = dataManager.load(lc);
    assertEquals(server1, latest);
}
Also used : Server(com.haulmont.cuba.core.entity.Server) Test(org.junit.Test)

Aggregations

Server (com.haulmont.cuba.core.entity.Server)33 Test (org.junit.Test)25 UUID (java.util.UUID)10 Entity (com.haulmont.cuba.core.entity.Entity)8 Before (org.junit.Before)4 UserSession (com.haulmont.cuba.security.global.UserSession)3 TestUserSessionSource (com.haulmont.cuba.testsupport.TestUserSessionSource)3 Date (java.util.Date)3 EntityManager (com.haulmont.cuba.core.EntityManager)2 Transaction (com.haulmont.cuba.core.Transaction)2 LoginWorker (com.haulmont.cuba.security.app.LoginWorker)2 User (com.haulmont.cuba.security.entity.User)2 QueryRunner (com.haulmont.bali.db.QueryRunner)1 Instance (com.haulmont.chile.core.model.Instance)1 DataService (com.haulmont.cuba.core.app.DataService)1 BaseGenericIdEntity (com.haulmont.cuba.core.entity.BaseGenericIdEntity)1 EntitySnapshot (com.haulmont.cuba.core.entity.EntitySnapshot)1 FileDescriptor (com.haulmont.cuba.core.entity.FileDescriptor)1 EntityDiff (com.haulmont.cuba.core.entity.diff.EntityDiff)1 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)1