@Test public void verify_generated_class_against_reference() throws IOException { String testDefinition = String.join("\n", Files.readAllLines(FileSystems.getDefault().getPath(DEF_NAME))); List<String> referenceClassLines = Files.readAllLines(FileSystems.getDefault().getPath(REFERENCE_NAME)); DefParser parser = new DefParser("allfeatures", new StringReader(testDefinition)); InnerCNode root = parser.getTree(); JavaClassBuilder builder = new JavaClassBuilder(root, parser.getNormalizedDefinition(), null, null); String[] configClassLines = builder.getConfigClass("AllfeaturesConfig").split("\n"); for (int i = 0; i < referenceClassLines.size(); i++) { if (configClassLines.length <= i) fail("Missing lines i generated config class. First missing line:\n" + referenceClassLines.get(i)); assertEquals("Line " + i, referenceClassLines.get(i), configClassLines[i]); } }
public String getConfigClass(String className) { return getHeader() + "\n\n" + getRootClassDeclaration(root, className) + "\n\n" + indentCode(INDENTATION, getFrameworkCode()) + "\n\n" + ConfigGenerator.generateContent(INDENTATION, root, true) + "\n" + "}\n"; }
JavaClassBuilder implements ClassBuilder { public String getConfigClass(String className) { return getHeader() + "\n\n" + getRootClassDeclaration(root, className) + "\n\n" + indentCode(INDENTATION, getFrameworkCode()) + "\n\n" + ConfigGenerator.generateContent(INDENTATION, root, true) + "\n" + "}\n"; } }
JavaClassBuilder implements ClassBuilder { public String getConfigClass(String className) { return getHeader() + "\n\n" + getRootClassDeclaration(root, className) + "\n\n" + indentCode(INDENTATION, getFrameworkCode()) + "\n\n" + ConfigGenerator.generateContent(INDENTATION, root, true) + "\n" + "}\n"; } JavaClassBuilder(InnerCNode root, NormalizedDefinition nd, File destDir, String rawPackagePrefix); }
JavaClassBuilder implements ClassBuilder { public String getConfigClass(String className) { return getHeader() + "\n\n" + getRootClassDeclaration(root, className) + "\n\n" + indentCode(INDENTATION, getFrameworkCode()) + "\n\n" + ConfigGenerator.generateContent(INDENTATION, root, true) + "\n" + "}\n"; } JavaClassBuilder(InnerCNode root, NormalizedDefinition nd, File destDir, String rawPackagePrefix); @Override void createConfigClasses(); String getConfigClass(String className); String className(); String javaPackage(); }
JavaClassBuilder implements ClassBuilder { public String getConfigClass(String className) { return getHeader() + "\n\n" + getRootClassDeclaration(root, className) + "\n\n" + indentCode(INDENTATION, getFrameworkCode()) + "\n\n" + ConfigGenerator.generateContent(INDENTATION, root, true) + "\n" + "}\n"; } JavaClassBuilder(InnerCNode root, NormalizedDefinition nd, File destDir, String rawPackagePrefix); @Override void createConfigClasses(); String getConfigClass(String className); String className(); String javaPackage();  }