Search in sources :

Example 6 with ProcessingMessage

use of com.github.fge.jsonschema.core.report.ProcessingMessage in project rest-assured by rest-assured.

the class JsonSchemaValidator method describeTo.

public void describeTo(Description description) {
    if (report != null) {
        description.appendText("The content to match the given JSON schema.\n");
        List<ProcessingMessage> messages = Lists.newArrayList(report);
        if (!messages.isEmpty()) {
            for (final ProcessingMessage message : messages) description.appendText(message.toString());
        }
    }
}
Also used : ProcessingMessage(com.github.fge.jsonschema.core.report.ProcessingMessage)

Example 7 with ProcessingMessage

use of com.github.fge.jsonschema.core.report.ProcessingMessage in project ocvn by devgateway.

the class ReleaseExportTest method testReleaseExportIsValid.

@Test
public void testReleaseExportIsValid() throws Exception {
    final ClassLoader classLoader = getClass().getClassLoader();
    final File file = new File(classLoader.getResource("json/award-release-test.json").getFile());
    final JsonImport releaseJsonImport = new ReleaseJsonImport(releaseRepository, file, false);
    final Release release = (Release) releaseJsonImport.importObject();
    final MvcResult result = this.mockMvc.perform(MockMvcRequestBuilders.get("/api/ocds/release/ocid/" + release.getOcid()).accept(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();
    final String content = result.getResponse().getContentAsString();
    final JsonNode jsonNodeResponse = JsonLoader.fromString(content);
    final OcdsSchemaValidatorService.ProcessingReportWithNode processingReport = ocdsSchemaValidator.validate(jsonNodeResponse);
    if (!processingReport.getReport().isSuccess()) {
        for (ProcessingMessage processingMessage : processingReport.getReport()) {
            logger.error(">>> processingMessage: \n" + processingMessage);
        }
    }
    Assert.assertEquals("Is the release valid?", true, processingReport.getReport().isSuccess());
}
Also used : ReleaseJsonImport(org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport) JsonImport(org.devgateway.ocds.persistence.mongo.spring.json.JsonImport) ProcessingMessage(com.github.fge.jsonschema.core.report.ProcessingMessage) ReleaseJsonImport(org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport) JsonNode(com.fasterxml.jackson.databind.JsonNode) MvcResult(org.springframework.test.web.servlet.MvcResult) OcdsSchemaValidatorService(org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService) File(java.io.File) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractWebTest(org.devgateway.toolkit.web.AbstractWebTest)

Example 8 with ProcessingMessage

use of com.github.fge.jsonschema.core.report.ProcessingMessage in project ocvn by devgateway.

the class ReleaseExportTest method testWholeStandardIsImplemented.

@Test
public void testWholeStandardIsImplemented() throws Exception {
    final ClassLoader classLoader = getClass().getClassLoader();
    final File file = new File(classLoader.getResource("json/full-release.json").getFile());
    final JsonImport releaseJsonImport = new ReleaseJsonImport(releaseRepository, file, false);
    final Release release = (Release) releaseJsonImport.importObject();
    final MvcResult result = this.mockMvc.perform(MockMvcRequestBuilders.get("/api/ocds/release/ocid/" + release.getOcid()).accept(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();
    final String content = result.getResponse().getContentAsString();
    final JsonNode jsonNodeResponse = JsonLoader.fromString(content);
    final OcdsSchemaValidatorService.ProcessingReportWithNode processingReport = ocdsSchemaAllRequiredValidator.validate(jsonNodeResponse);
    if (!processingReport.getReport().isSuccess()) {
        for (ProcessingMessage processingMessage : processingReport.getReport()) {
            logger.error(">>> processingMessage: \n" + processingMessage);
        }
    }
    Assert.assertEquals("Do we implement the entire standard (with all fields required)?", true, processingReport.getReport().isSuccess());
}
Also used : ReleaseJsonImport(org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport) JsonImport(org.devgateway.ocds.persistence.mongo.spring.json.JsonImport) ProcessingMessage(com.github.fge.jsonschema.core.report.ProcessingMessage) ReleaseJsonImport(org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport) JsonNode(com.fasterxml.jackson.databind.JsonNode) MvcResult(org.springframework.test.web.servlet.MvcResult) OcdsSchemaValidatorService(org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService) File(java.io.File) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractWebTest(org.devgateway.toolkit.web.AbstractWebTest)

Example 9 with ProcessingMessage

use of com.github.fge.jsonschema.core.report.ProcessingMessage in project ocvn by devgateway.

the class ReleaseExportTest method testWholeStandardIsImplemented.

@Test
public void testWholeStandardIsImplemented() throws Exception {
    final ClassLoader classLoader = getClass().getClassLoader();
    final File file = new File(classLoader.getResource("json/full-release.json").getFile());
    final JsonImport releaseJsonImport = new ReleaseJsonImport(releaseRepository, file, false);
    final Release release = (Release) releaseJsonImport.importObject();
    final MvcResult result = this.mockMvc.perform(MockMvcRequestBuilders.get("/api/ocds/release/ocid/" + release.getOcid()).accept(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();
    final String content = result.getResponse().getContentAsString();
    final JsonNode jsonNodeResponse = JsonLoader.fromString(content);
    final OcdsSchemaValidatorService.ProcessingReportWithNode processingReport = ocdsSchemaAllRequiredValidator.validate(jsonNodeResponse);
    if (!processingReport.getReport().isSuccess()) {
        for (ProcessingMessage processingMessage : processingReport.getReport()) {
            logger.error(">>> processingMessage: \n" + processingMessage);
        }
    }
    Assert.assertEquals("Do we implement the entire standard (with all fields required)?", true, processingReport.getReport().isSuccess());
}
Also used : ReleaseJsonImport(org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport) JsonImport(org.devgateway.ocds.persistence.mongo.spring.json.JsonImport) ProcessingMessage(com.github.fge.jsonschema.core.report.ProcessingMessage) ReleaseJsonImport(org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport) JsonNode(com.fasterxml.jackson.databind.JsonNode) MvcResult(org.springframework.test.web.servlet.MvcResult) OcdsSchemaValidatorService(org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService) File(java.io.File) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractWebTest(org.devgateway.toolkit.web.AbstractWebTest)

Example 10 with ProcessingMessage

use of com.github.fge.jsonschema.core.report.ProcessingMessage in project oc-explorer by devgateway.

the class ReleaseExportTest method testReleaseExportIsValid.

@Test
public void testReleaseExportIsValid() throws Exception {
    final ClassLoader classLoader = getClass().getClassLoader();
    final File file = new File(classLoader.getResource("json/award-release-test.json").getFile());
    final JsonImport releaseJsonImport = new ReleaseJsonImport(releaseRepository, file);
    final Release release = (Release) releaseJsonImport.importObject();
    final MvcResult result = this.mockMvc.perform(MockMvcRequestBuilders.get("/api/ocds/release/ocid/" + release.getOcid()).accept(MediaType.APPLICATION_JSON_UTF8)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)).andReturn();
    final String content = result.getResponse().getContentAsString();
    final JsonNode jsonNodeResponse = JsonLoader.fromString(content);
    final OcdsSchemaValidatorService.ProcessingReportWithNode processingReport = ocdsSchemaValidator.validate(jsonNodeResponse);
    if (!processingReport.getReport().isSuccess()) {
        for (ProcessingMessage processingMessage : processingReport.getReport()) {
            logger.error(">>> processingMessage: \n" + processingMessage);
        }
    }
    Assert.assertEquals("Is the release valid?", true, processingReport.getReport().isSuccess());
}
Also used : ReleaseJsonImport(org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport) JsonImport(org.devgateway.ocds.persistence.mongo.spring.json.JsonImport) ProcessingMessage(com.github.fge.jsonschema.core.report.ProcessingMessage) ReleaseJsonImport(org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport) JsonNode(com.fasterxml.jackson.databind.JsonNode) MvcResult(org.springframework.test.web.servlet.MvcResult) OcdsSchemaValidatorService(org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService) File(java.io.File) Release(org.devgateway.ocds.persistence.mongo.Release) Test(org.junit.Test) AbstractWebTest(org.devgateway.toolkit.web.AbstractWebTest)

Aggregations

ProcessingMessage (com.github.fge.jsonschema.core.report.ProcessingMessage)14 JsonNode (com.fasterxml.jackson.databind.JsonNode)11 File (java.io.File)6 Release (org.devgateway.ocds.persistence.mongo.Release)6 OcdsSchemaValidatorService (org.devgateway.ocds.persistence.mongo.spring.OcdsSchemaValidatorService)6 JsonImport (org.devgateway.ocds.persistence.mongo.spring.json.JsonImport)6 ReleaseJsonImport (org.devgateway.ocds.persistence.mongo.spring.json.ReleaseJsonImport)6 AbstractWebTest (org.devgateway.toolkit.web.AbstractWebTest)6 Test (org.junit.Test)6 MvcResult (org.springframework.test.web.servlet.MvcResult)6 ProcessingReport (com.github.fge.jsonschema.core.report.ProcessingReport)5 ProcessingException (com.github.fge.jsonschema.core.exceptions.ProcessingException)4 IOException (java.io.IOException)4 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 JsonSchema (com.github.fge.jsonschema.main.JsonSchema)2 InputStreamReader (java.io.InputStreamReader)2 ArrayList (java.util.ArrayList)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1