Package com.gatehill.apib.parser.model.result

Examples of com.gatehill.apib.parser.model.result.AstResult


        final ParsingResult<File> actual = parser.convertToAstFile(config, blueprintFile, AstFormat.JSON);

        // assert output
        Assert.assertNotNull(actual);

        final AstResult result = actual.getResult();
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getError());
        Assert.assertEquals(AstResult.ErrorCode.NoError.getErrorCode(), result.getError().getCode());
        Assert.assertNotNull(result.getWarnings());
        Assert.assertEquals(0, result.getWarnings().length);

        final File astFile = actual.getAst();
        Assert.assertNotNull(astFile);
        Assert.assertTrue(astFile.getAbsolutePath().endsWith(".json"));
        Assert.assertTrue("AST file exists", astFile.exists());
View Full Code Here


        final ParsingResult<File> actual = parser.convertToAstFile(config, blueprintFile, AstFormat.YAML);

        // assert output
        Assert.assertNotNull(actual);

        final AstResult result = actual.getResult();
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getError());
        Assert.assertEquals(AstResult.ErrorCode.NoError.getErrorCode(), result.getError().getCode());
        Assert.assertNotNull(result.getWarnings());
        Assert.assertEquals(0, result.getWarnings().length);

        final File astFile = actual.getAst();
        Assert.assertNotNull(astFile);
        Assert.assertTrue(astFile.getAbsolutePath().endsWith(".yaml"));
        Assert.assertTrue("AST file exists", astFile.exists());
View Full Code Here

        final ParsingResult<String> actual = parser.convertToAstString(config, blueprintFile, AstFormat.JSON);

        // assert output
        Assert.assertNotNull(actual);

        final AstResult result = actual.getResult();
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getError());
        Assert.assertEquals(AstResult.ErrorCode.NoError.getErrorCode(), result.getError().getCode());
        Assert.assertNotNull(result.getWarnings());
        Assert.assertEquals(0, result.getWarnings().length);

        Assert.assertNotNull(actual.getAst());
    }
View Full Code Here

        final ParsingResult<InputStream> actual = parser.convertToAstStream(config, blueprintFile, AstFormat.YAML);

        // assert output
        Assert.assertNotNull(actual);

        final AstResult result = actual.getResult();
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getError());
        Assert.assertEquals(AstResult.ErrorCode.NoError.getErrorCode(), result.getError().getCode());
        Assert.assertNotNull(result.getWarnings());
        Assert.assertEquals(0, result.getWarnings().length);

        Assert.assertNotNull(actual.getAst());
        Assert.assertNotNull("Stream should have content", IOUtils.toString(actual.getAst()));
    }
View Full Code Here

        if (StringUtils.isNotBlank(stderr)) {
            output += "\r\n" + stderr;
        }
        LOGGER.debug("Parser output: {}", output.trim());

        final AstResult parserResult = ResultUtil.getParserResult(output);
        result.setResult(parserResult);
        LOGGER.debug("Parser result: {}", parserResult);

        // check exit code
        if (0 != exitCode) {
View Full Code Here

        final ParsingResult<File> actual = blueprintParserService.convertToAstFile(config, blueprintFile, AstFormat.JSON);

        // assert output
        Assert.assertNotNull(actual);

        final AstResult result = actual.getResult();
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getError());
        Assert.assertEquals(AstResult.ErrorCode.NoError.getErrorCode(), result.getError().getCode());
        Assert.assertNotNull(result.getWarnings());
        Assert.assertEquals(0, result.getWarnings().length);

        final File astFile = actual.getAst();
        Assert.assertNotNull(astFile);
        Assert.assertTrue(astFile.getAbsolutePath().endsWith(".json"));
        Assert.assertTrue("AST file exists", astFile.exists());
View Full Code Here

        final ParsingResult<File> actual = blueprintParserService.convertToAstFile(config, blueprintFile, AstFormat.JSON);

        // assert output
        Assert.assertNotNull(actual);

        final AstResult result = actual.getResult();
        Assert.assertNotNull(result);
        Assert.assertNotNull(result.getError());
        Assert.assertEquals(AstResult.ErrorCode.NoError.getErrorCode(), result.getError().getCode());
        Assert.assertNotNull(result.getWarnings());
        Assert.assertEquals(0, result.getWarnings().length);

        final File astFile = actual.getAst();
        Assert.assertNotNull(astFile);
        Assert.assertTrue(astFile.getAbsolutePath().endsWith(".json"));
        Assert.assertTrue("AST file exists", astFile.exists());
View Full Code Here

        if (null == output) {
            LOGGER.warn("Parser result was null");
            return null;
        }

        final AstResult astResult = new AstResult();
        final List<SourceAnnotation> warnings = new ArrayList<SourceAnnotation>();

        // TODO should this use the LINE_SEPARATOR_UNIX instead of the system separator?
        for (String line : StringUtils.split(output, IOUtils.LINE_SEPARATOR)) {
            line = line.trim();
            if (0 == line.length()) {
                continue;
            }
            LOGGER.trace("Attempt to parse result line: {}", line);

            if (RESULT_OK.equals(line)) {
                astResult.setError(new SourceAnnotation(AstResult.ErrorCode.NoError.getErrorCode(), null, null));

            } else if (line.startsWith(RESULT_ERROR)) {
                line = line.substring(RESULT_ERROR.length() + 1).trim();
                astResult.setError(getSourceAnnotation(line));

            } else if (line.startsWith(RESULT_WARNING)) {
                line = line.substring(RESULT_WARNING.length() + 1).trim();
                warnings.add(getSourceAnnotation(line));

            } else {
                LOGGER.warn("Result line did not match any expected format: {}" + line);
            }
        }

        astResult.setWarnings(warnings.toArray(new SourceAnnotation[warnings.size()]));

        return astResult;
    }
View Full Code Here

    public void testGetParserResult_OK() throws IOException {
        // test data
        final File parserResult = new File(ResultUtilTest.class.getResource("/result_ok.txt").getPath());

        // call
        final AstResult actual = ResultUtil.getParserResult(FileUtils.readFileToString(parserResult));

        // assert output
        Assert.assertNotNull(actual);

        // assert error
        Assert.assertNotNull(actual.getError());
        Assert.assertEquals(AstResult.ErrorCode.NoError.getErrorCode(), actual.getError().getCode());
        Assert.assertNull(actual.getError().getMessage());
        Assert.assertNull(actual.getError().getLocation());

        // assert warnings
        Assert.assertNotNull(actual.getWarnings());
        Assert.assertEquals(0, actual.getWarnings().length);
    }
View Full Code Here

    public void testGetParserResult_Error() throws IOException {
        // test data
        final File parserResult = new File(ResultUtilTest.class.getResource("/result_error.txt").getPath());

        // call
        final AstResult actual = ResultUtil.getParserResult(FileUtils.readFileToString(parserResult));

        // assert output
        Assert.assertNotNull(actual);

        // assert error
        Assert.assertNotNull(actual.getError());
        Assert.assertEquals(AstResult.ErrorCode.BusinessError.getErrorCode(), actual.getError().getCode());
        Assert.assertEquals("unexpected header block, expected a group, resource or an action definition, e.g. '# Group <name>', '# <resource name> [<URI>]' or '# <HTTP method> <URI>'",
                actual.getError().getMessage());

        Assert.assertNotNull(actual.getError().getLocation());
        Assert.assertEquals(826, actual.getError().getLocation().getLocation());
        Assert.assertEquals(8, actual.getError().getLocation().getLength());

        // assert warnings
        Assert.assertNotNull(actual.getWarnings());
        Assert.assertEquals(0, actual.getWarnings().length);
    }
View Full Code Here

TOP

Related Classes of com.gatehill.apib.parser.model.result.AstResult

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.