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"));
}
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());
}
Aggregations