PojoMapper { public static Pojo procedureToPojo(Procedure procedure) { Pojo p = new Pojo(); p.setClassName(procedure.getStoredProcedureClassName()); p.setFields(new ArrayList<PojoField>()); for (ProcedureArgument t : procedure.getArgumentList()) { PojoField field = new PojoField(); field.setFieldName(t.getJavaPropertyName()); field.setFieldType(t.getJavaDataType()); p.getFields().add(field); } p.setImports(new ArrayList<String>()); p.getImports().add("java.sql.Timestamp"); p.getImports().add("java.sql.Date"); p.getImports().add("java.util.List"); p.getImports().add("java.math.BigDecimal"); p.getImports().add("java.sql.ResultSet"); return p; } private  PojoMapper(); static Pojo typeToPojo(String typeName, List<TypeAttribute> typeAttributes); static Pojo procedureToPojo(Procedure procedure);  }
@Test public void testToPojo2() { List<Procedure> simple_procedures = procedureDao.getAllProcedure("SIMPLE_PROCEDURES", "OBRIDGE", null, null); Procedure ppp = null; for (Procedure pp : simple_procedures) { if (pp.getProcedureName().equals("OVERLOAD") && pp.getOverload().equals("2")) { ppp = pp; } } Pojo pojo = PojoMapper.procedureToPojo(ppp); Assert.assertEquals("SimpleProceduresOverload2", pojo.getClassName()); Assert.assertEquals(1, pojo.getFields().size()); }
@Test public void testToPojo3() { List<Procedure> simple_procedures = procedureDao.getAllProcedure("SIMPLE_PROCEDURES", "OBRIDGE", null, null); Procedure ppp = null; for (Procedure pp : simple_procedures) { if (pp.getProcedureName().equals("SIMPLE_FUNC") && pp.getOverload().equals("")) { ppp = pp; } } Pojo pojo = PojoMapper.procedureToPojo(ppp); Assert.assertEquals("SimpleProceduresSimpleFunc", pojo.getClassName()); Assert.assertEquals(4, pojo.getFields().size()); MustacheRunner.build("pojo.mustache", pojo); }