Package com.indeed.proctor.consumer.gen

Examples of com.indeed.proctor.consumer.gen.CodeGenException


    /*
     * Generates total specifications from any partial specifications found
     */
    private void totalSpecificationGenerator(final File dir) throws CodeGenException {
        if (dir.equals(null)) {
            throw new CodeGenException("input directory creates null file");
        }
        final File[] providedContextFiles = dir.listFiles((java.io.FileFilter) FileFilterUtils.andFileFilter(FileFilterUtils.fileFileFilter(), FileFilterUtils.nameFileFilter("providedcontext.json")));
        if (providedContextFiles.length == 1) {
            //make directory if it doesn't exist
            (new File(specificationOutput.substring(0,specificationOutput.lastIndexOf(File.separator)))).mkdirs();
            final File specificationOutputFile = new File(specificationOutput);
            final File output = gen.makeTotalSpecification(dir, specificationOutputFile.getParent(), specificationOutputFile.getName());
            gen.generate(output.getPath(),target,packageName,groupsClass,groupsManagerClass);
        } else {
            throw new CodeGenException("Incorrect amount of providedcontext.json in specified input folder");
        }
    }
View Full Code Here


     * traverse through main specification folder to find large proctor specifications (determined if they have the test
     * attribute)
     */
    private void recursiveSpecificationsFinder(final File dir, final String packageNamePrefix) throws CodeGenException {
        if (dir.equals(null)) {
            throw new CodeGenException("recursiveSpecificationsFinder called with null pointer");
        }
        final File[] files = dir.listFiles();
        if (files == null) {
            return;
        }
        for(final File entry : files) {
            try {
                if (entry.isDirectory()) {
                    recursiveSpecificationsFinder(entry, (packageNamePrefix == null) ? entry.getName() : packageNamePrefix + "/" + entry.getName());
                } else if (entry.getName().endsWith(".json") && ProctorUtils.readJsonFromFile(entry).has("tests")) {
                    processFile(
                            entry,
                            packageNamePrefix == null ? "" : packageNamePrefix.replace("/", "."),
                            entry.getName().substring(0, entry.getName().lastIndexOf(".json")));
                }

            } catch (IOException e) {
                throw new CodeGenException("Could not read from file " + entry.getName(),e);
            }
        }
    }
View Full Code Here

    /*
     * Adds any non partial specifications to resources
     */
    private void addNonPartialsToResources(final File dir, final Resource resource) throws CodeGenException {
        if (dir.equals(null)) {
            throw new CodeGenException("Could not read from directory " + dir.getPath());
        }
        final File[] files = dir.listFiles();
        if (files == null) {
            return;
        }
        for(File entry : files) {
            try {
                if (entry.isDirectory()) {
                    addNonPartialsToResources(entry, resource);
                } else if (entry.getName().endsWith(".json") && ProctorUtils.readJsonFromFile(entry).has("tests")) {
                    resource.addInclude(entry.getPath().substring(getTopDirectory().getPath().length() + 1));
                }
            } catch (IOException e) {
                throw new CodeGenException("Could not read from file " + entry.getName(),e);
            }

        }
    }
View Full Code Here

TOP

Related Classes of com.indeed.proctor.consumer.gen.CodeGenException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.