Search in sources :

Example 16 with Revapi

use of org.revapi.Revapi in project revapi by revapi.

the class RevapiTask method execute.

@Override
public void execute() throws BuildException {
    Revapi revapi = initRevapi();
    AnalysisContext context = initAnalysisContext(revapi);
    log("Running API analysis");
    log("Old API: " + context.getOldApi().toString());
    log("New API: " + context.getNewApi().toString());
    try (AnalysisResult res = revapi.analyze(context)) {
        res.throwIfFailed();
    } catch (Exception e) {
        throw new BuildException("API analysis failed.", e);
    }
}
Also used : Revapi(org.revapi.Revapi) AnalysisContext(org.revapi.AnalysisContext) BuildException(org.apache.tools.ant.BuildException) AnalysisResult(org.revapi.AnalysisResult) MalformedURLException(java.net.MalformedURLException) BuildException(org.apache.tools.ant.BuildException)

Example 17 with Revapi

use of org.revapi.Revapi in project revapi by revapi.

the class ConfigurationValidatorTest method testRevapiValidation_mergeWithIds.

@Test
public void testRevapiValidation_mergeWithIds() throws Exception {
    String config1 = "[" + "{\"extension\": \"my-config\", \"id\": \"c1\", \"configuration\": {\"id\": 3, \"kachna\": \"duck\"}}" + "]";
    String config2 = "[" + "{\"extension\": \"my-config\", \"id\": \"c2\", \"configuration\": {\"id\": 4, \"kachna\": \"no duck\"}}," + "{\"extension\": \"other-config\", \"configuration\": 1}" + "]";
    Revapi revapi = Revapi.builder().withFilters(TestFilter.class).withReporters(TestReporter.class).withAnalyzers(DummyApiAnalyzer.class).build();
    AnalysisContext ctx = AnalysisContext.builder(revapi).withConfigurationFromJSON(config1).mergeConfigurationFromJSON(config2).build();
    ValidationResult res = revapi.validateConfiguration(ctx);
    Assert.assertFalse(res.isSuccessful());
    Assert.assertNotNull(res.getErrors());
    Assert.assertEquals(1, res.getErrors().length);
    Assert.assertEquals("/[2]/configuration", res.getErrors()[0].dataPath);
}
Also used : Revapi(org.revapi.Revapi) AnalysisContext(org.revapi.AnalysisContext) Test(org.junit.Test)

Aggregations

Revapi (org.revapi.Revapi)17 AnalysisContext (org.revapi.AnalysisContext)15 AnalysisResult (org.revapi.AnalysisResult)9 Test (org.junit.Test)8 File (java.io.File)5 API (org.revapi.API)4 StringWriter (java.io.StringWriter)3 List (java.util.List)3 ModelNode (org.jboss.dmr.ModelNode)3 Report (org.revapi.Report)3 BufferedReader (java.io.BufferedReader)2 FileInputStream (java.io.FileInputStream)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 PrintWriter (java.io.PrintWriter)2 MalformedURLException (java.net.MalformedURLException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 MavenProject (org.apache.maven.project.MavenProject)2