public void testCaseWhen() throws Exception { session.tranSync(WriteJobs.dummy("/bleujin", 10)); Rows rows = session .pathBy("/bleujin") .children() .toRows( Page.TEN, "(case when this.name='dummy' then true else false end) as isbleujin"); // rows.debugPrint() ; assertEquals(true, rows.firstRow().getBoolean("isbleujin")); }
public void testAradonQuery() throws Exception { AradonTester at = AradonTester.create().register("", "/query", QueryLet.class); at.getAradon().getServiceContext().putAttribute(IDBController.class.getCanonicalName(), dc); IUserCommand cmd = dc.createUserCommand("select 1 from dual"); ISerialRequest req = AradonClientFactory.create(at.getAradon()).createSerialRequest("/query"); Rows rows = req.post(cmd, Rows.class); assertEquals(1, rows.getRowCount()); assertEquals(1, rows.firstRow().getInt(1)); }
public void testFunction() throws Exception { session.tranSync( new WriteJob<Void>() { @Override public Void handle(WriteSession wsession) throws Exception { wsession.pathBy("/emps/bleujin").property("name", "bleujin").refTo("dept", "/dept/dev"); wsession.pathBy("/dept/dev").property("name", "dev").refTo("manager", "/emps/bleujin"); return null; } }); Rows rows = session.pathBy("/emps").children().toRows("substring(this.name, 2) s"); rows.debugPrint(); }
public void testDebugPrint() throws Exception { session.tranSync( new WriteJob<Void>() { @Override public Void handle(WriteSession wsession) throws Exception { wsession.pathBy("/bleujin").property("name", "bleujin").property("age", 20); return null; } }); Rows rows = session.root().children().toRows("this.name b, this.age"); rows.debugPrint(); }
public void testFirst() throws Exception { dc.addServant(new StdOutServant()); Rows rows = dc.tran( new TransactionJob<Rows>() { public Rows handle(WriteSession wsession) { wsession .createProcedure("select@dual(:name, :age)") .param("name", "bleujin") .param("age", 20) .execQuery(); return null; } }); JsonObject jso = rows.toHandle(new JSONHandler()); }
public void testOldInterface() throws Exception { session.tranSync(WriteJobs.dummy("/bleujin", 120)); Rows rows = session .pathBy("/bleujin") .children() .ascending("dummy") .toRows(Page.create(10, 11, 10), "this.name b, dummy, this.age"); assertEquals(20, rows.firstRow().getInt("cnt")); assertEquals(100, rows.firstRow().getInt("dummy")); rows = session .pathBy("/bleujin") .children() .ascending("dummy") .toRows(Page.create(10, 5, 10), "this.name b, dummy, this.age"); assertEquals(101, rows.firstRow().getInt("cnt")); assertEquals(40, rows.firstRow().getInt("dummy")); }
public void testDateType() throws Exception { session.tranSync( new WriteJob<Void>() { @Override public Void handle(WriteSession wsession) { wsession .pathBy("/bleujin") .property("int", 1) .property("str", "string") .property("lng", 1L) .property("dte", new Date()); return null; } }); Rows rows = session.root().children().eq("int", 1).toRows("int, str, lng, dte"); rows.first(); // assertEquals("1", rows.getString("int")); // assertEquals("string", rows.getString("str")); // assertEquals("1", rows.getString("lng")); assertEquals(1, rows.getInt("int")); assertEquals("string", rows.getString("str")); assertEquals(1L, rows.getLong("lng")); assertEquals(new Date().getDate(), rows.getDate("dte").getDate()); }
public void testJSONHandler() throws Exception { Rows rows = dc.createUserProcedure("sample@selectEmpBy()").execQuery(); JsonObject jso = (JsonObject) rows.toHandle(new JSONHandler()); Debug.debug(jso); }