Search in sources :

Example 11 with KeyValueEntity

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

the class NonEntityQueryTest method testScalars.

@Test
public void testScalars() throws Exception {
    ValueLoadContext context = ValueLoadContext.create().setQuery(ValueLoadContext.createQuery("select u.id, u.login from sec$User u where u.id = :id1 or u.id = :id2 order by u.login").setParameter("id1", TestSupport.ADMIN_USER_ID).setParameter("id2", TestSupport.ANONYMOUS_USER_ID)).addProperty("user1Id").addProperty("login");
    List<KeyValueEntity> list = dataManager.loadValues(context);
    assertEquals(2, list.size());
    KeyValueEntity e = list.get(0);
    assertEquals(TestSupport.ADMIN_USER_ID, e.getValue("user1Id"));
    assertEquals("admin", e.getValue("login"));
    e = list.get(1);
    assertEquals(TestSupport.ANONYMOUS_USER_ID, e.getValue("user1Id"));
    assertEquals("anonymous", e.getValue("login"));
}
Also used : KeyValueEntity(com.haulmont.cuba.core.entity.KeyValueEntity) Test(org.junit.Test)

Example 12 with KeyValueEntity

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

the class NonEntityQueryTest method testIdentificationVariable.

@Test
public void testIdentificationVariable() throws Exception {
    ValueLoadContext context = ValueLoadContext.create();
    ValueLoadContext.Query query = context.setQueryString("select u, u.id from sec$User u where u.id = :id1");
    query.setParameter("id1", TestSupport.ADMIN_USER_ID);
    context.addProperty("user");
    context.addProperty("id");
    List<KeyValueEntity> list = dataManager.secure().loadValues(context);
    assertEquals(1, list.size());
    KeyValueEntity e = list.get(0);
    assertEquals(TestSupport.ADMIN_USER_ID, ((User) e.getValue("user")).getId());
}
Also used : KeyValueEntity(com.haulmont.cuba.core.entity.KeyValueEntity) Test(org.junit.Test)

Aggregations

KeyValueEntity (com.haulmont.cuba.core.entity.KeyValueEntity)12 Test (org.junit.Test)6 LoginWorker (com.haulmont.cuba.security.app.LoginWorker)3 UserSession (com.haulmont.cuba.security.global.UserSession)3 TestUserSessionSource (com.haulmont.cuba.testsupport.TestUserSessionSource)3 MetaProperty (com.haulmont.chile.core.model.MetaProperty)1 ConfigStorageService (com.haulmont.cuba.core.app.ConfigStorageService)1 KeyValueMetaProperty (com.haulmont.cuba.core.app.keyvalue.KeyValueMetaProperty)1 BuildInfo (com.haulmont.cuba.core.global.BuildInfo)1 ValueLoadContext (com.haulmont.cuba.core.global.ValueLoadContext)1 Map (java.util.Map)1