DomaEntityTask implements GenTask { @Override public void execute(PathResolver pathResolver) throws Exception { final Project project = new Project(); project.setBaseDir(pathResolver.project()); String basePackage = BasePackageDetector.detect(); File destDir = pathResolver.destinationAsFile(destination); Gen genTask = new Gen() { @Override protected DataSource createDataSource() { return datasource; } @Override public EntityConfig createEntityConfig() { entityConfig = new EntityConfig(); entityConfig.setProject(getProject()); entityConfig.setUseListener(false); entityConfig.setDestDir(destDir); GenerationTypeAttribute generationType = new GenerationTypeAttribute(); generationType.setValue("identity"); entityConfig.setGenerationType(generationType); entityConfig.setPackageName(basePackage + "entity"); return entityConfig; } @Override public DaoConfig createDaoConfig() { daoConfig = new DaoConfig(); daoConfig.setProject(getProject()); daoConfig.setDestDir(destDir); daoConfig.setPackageName(basePackage + "dao"); return daoConfig; } @Override public SqlConfig createSqlConfig() { sqlConfig = new SqlConfig(); sqlConfig.setProject(getProject()); sqlConfig.setDestDir(new File(destination)); return sqlConfig; } }; genTask.setProject(project); genTask.setUrl(getURL()); genTask.setUser(""); genTask.setPassword(""); genTask.setTableNamePattern(tableName); genTask.createEntityConfig(); genTask.execute(); } DomaEntityTask(String destination, String tableName, DataSource datasource); @Override void execute(PathResolver pathResolver); @Override String getDestinationPath();  }
@Test void test() throws Exception { JdbcDataSource ds = new JdbcDataSource(); ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1"); createTable(ds); DomaEntityTask task = new DomaEntityTask("example/entity", "product", ds); PathResolverMock resolver = new PathResolverMock(); task.execute(resolver); }