Examples of AstResult


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

    public void testGetParserResult_Warnings() throws IOException {
        // test data
        final File parserResult = new File(ResultUtilTest.class.getResource("/result_warnings.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(3, actual.getWarnings().length);

        final SourceAnnotation warning1 = actual.getWarnings()[0];
        Assert.assertNotNull(warning1);
        Assert.assertEquals(WARNING_MESSAGE, warning1.getMessage());
        Assert.assertEquals(AstResult.WarningCode.EmptyDefinitionWarning.getWarningCode(), warning1.getCode());
        Assert.assertNotNull(warning1.getLocation());
        Assert.assertEquals(641, warning1.getLocation().getLocation());
        Assert.assertEquals(34, warning1.getLocation().getLength());

        final SourceAnnotation warning2 = actual.getWarnings()[1];
        Assert.assertNotNull(warning2);
        Assert.assertEquals(WARNING_MESSAGE, warning2.getMessage());
        Assert.assertEquals(AstResult.WarningCode.IgnoringWarning.getWarningCode(), warning2.getCode());
        Assert.assertNotNull(warning2.getLocation());
        Assert.assertEquals(642, warning2.getLocation().getLocation());
        Assert.assertEquals(35, warning2.getLocation().getLength());

        final SourceAnnotation warning3 = actual.getWarnings()[2];
        Assert.assertNotNull(warning3);
        Assert.assertEquals(WARNING_MESSAGE, warning3.getMessage());
        Assert.assertEquals(AstResult.WarningCode.RedefinitionWarning.getWarningCode(), warning3.getCode());
        Assert.assertNotNull(warning3.getLocation());
        Assert.assertEquals(643, warning3.getLocation().getLocation());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.