// On teste un preparestatement mappé sur un type statique (Class famille) @Test public void testSelectPrimitive2() throws Exception { // On crée les données createDatas(); // ---- final Domain domain = new Domain("DO_LIB", DataType.String); final SqlQueryResult result = executeQuery(domain, "select title from movie where id=1"); Assert.assertEquals(1, result.getSQLRowCount()); Assert.assertEquals(TITLE_MOVIE_1, result.getValue()); }
// On teste un preparestatement mappé sur un type statique (Class famille) @Test public void testSelectPrimitive() throws Exception { // On crée les données createDatas(); // ---- final Domain domain = new Domain("DO_INTEGER", DataType.Integer); final SqlQueryResult result = executeQuery(domain, "select count(*) from movie"); Assert.assertEquals(1, result.getSQLRowCount()); Assert.assertEquals(3, result.getValue()); }
// On teste un preparestatement mappé sur un type statique (Class famille) @Test public void testSelectObject() throws Exception { // On crée les données createDatas(); // ---- final Domain domain = Home.getDefinitionSpace().resolve("DO_DT_MOVIE_DTO", Domain.class); final SqlQueryResult result = executeQuery(domain, "select * from movie where id=1"); Assert.assertEquals(1, result.getSQLRowCount()); final Movie movie = (Movie) result.getValue(); Assert.assertEquals("citizen kane", movie.getTitle()); }
// On teste un preparestatement mappé sur un type dynamique DTList. @Test public void testDynSelect() throws Exception { // On crée les données createDatas(); // ---- final Domain domain = new Domain("DO_TEST", DataType.DtList); final SqlQueryResult result = executeQuery(domain, "select * from movie"); Assert.assertEquals(3, result.getSQLRowCount()); final DtList<DtObject> dynMovies = (DtList<DtObject>) result.getValue(); Assert.assertEquals(3, dynMovies.size()); for (final DtObject dynMovie : dynMovies) { final long id = (Long) getValue(dynMovie, "ID"); final String title = (String) getValue(dynMovie, "TITLE"); checkTitle(id, title); } }
// On teste un preparestatement mappé sur un type statique (Class famille) @Test public void testSelectList() throws Exception { // On crée les données createDatas(); // ---- final Domain domain = Home.getDefinitionSpace().resolve("DO_DT_MOVIE_DTC", Domain.class); final SqlQueryResult result = executeQuery(domain, "select * from movie"); Assert.assertEquals(3, result.getSQLRowCount()); final DtList<Movie> movies = (DtList<Movie>) result.getValue(); Assert.assertEquals(3, movies.size()); for (final Movie movie : movies) { final long id = movie.getId(); final String title = movie.getTitle(); checkTitle(id, title); } }