@Test public void testPackageGeneration() { String metaPackage = "com.ebay.cloud.cms.model.metadata"; String genFolder = EntityGeneratorTest.class.getResource("/").getFile(); MetaJsonReader reader = new FileMetaJsonReader(metaPackage); CodeGenerator generator = new CodeGenerator(reader, genFolder, "test3.packagegenerate"); generator.generate(); URL packageUrl = CodeGeneratorTest.class.getResource("/test3/packagegenerate/"); Assert.assertNotNull(packageUrl); File f = new File(packageUrl.getPath()); Assert.assertTrue(f.exists()); File[] javaFiles = f.listFiles(new FileFilter() { @Override public boolean accept(File pathname) { return pathname.getName().endsWith(".java"); } }); Assert.assertTrue(javaFiles.length > 0); Assert.assertEquals(73, javaFiles.length); }
public void generate() { JsonNode metaJsons = metaReader.getMetaJson(); if (metaJsons.isArray()) { MetadataManager metaManager = MetadataManager.load(metaJsons); for (JsonNode metaNode : metaJsons) { EntityGenerator entityGenerator = new EntityGenerator(metaNode, packagePrefix, metaManager); entityGenerator.build(); output(entityGenerator.getEntity()); } } }
CodeGenerator { public void generate() { JsonNode metaJsons = metaReader.getMetaJson(); if (metaJsons.isArray()) { MetadataManager metaManager = MetadataManager.load(metaJsons); for (JsonNode metaNode : metaJsons) { EntityGenerator entityGenerator = new EntityGenerator(metaNode, packagePrefix, metaManager); entityGenerator.build(); output(entityGenerator.getEntity()); } } } }
CodeGenerator { public void generate() { JsonNode metaJsons = metaReader.getMetaJson(); if (metaJsons.isArray()) { MetadataManager metaManager = MetadataManager.load(metaJsons); for (JsonNode metaNode : metaJsons) { EntityGenerator entityGenerator = new EntityGenerator(metaNode, packagePrefix, metaManager); entityGenerator.build(); output(entityGenerator.getEntity()); } } } CodeGenerator(MetaJsonReader reader, String outputDirectory, String packagePrefix); }
CodeGenerator { public void generate() { JsonNode metaJsons = metaReader.getMetaJson(); if (metaJsons.isArray()) { MetadataManager metaManager = MetadataManager.load(metaJsons); for (JsonNode metaNode : metaJsons) { EntityGenerator entityGenerator = new EntityGenerator(metaNode, packagePrefix, metaManager); entityGenerator.build(); output(entityGenerator.getEntity()); } } } CodeGenerator(MetaJsonReader reader, String outputDirectory, String packagePrefix); void generate(); }
CodeGenerator { public void generate() { JsonNode metaJsons = metaReader.getMetaJson(); if (metaJsons.isArray()) { MetadataManager metaManager = MetadataManager.load(metaJsons); for (JsonNode metaNode : metaJsons) { EntityGenerator entityGenerator = new EntityGenerator(metaNode, packagePrefix, metaManager); entityGenerator.build(); output(entityGenerator.getEntity()); } } } CodeGenerator(MetaJsonReader reader, String outputDirectory, String packagePrefix); void generate(); final static String DEFAULT_PACKAGE_PREFIX; }