當前位置: 首頁>>代碼示例>>Java>>正文


Java ProcessingReport類代碼示例

本文整理匯總了Java中com.github.fge.jsonschema.core.report.ProcessingReport的典型用法代碼示例。如果您正苦於以下問題:Java ProcessingReport類的具體用法?Java ProcessingReport怎麽用?Java ProcessingReport使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ProcessingReport類屬於com.github.fge.jsonschema.core.report包,在下文中一共展示了ProcessingReport類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateJSonSchema

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
private static SwaggerModelInfo validateJSonSchema(final String specification, final Swagger model) {
    try {
        final JsonNode specRoot = convertToJson(specification);
        final ProcessingReport report = SWAGGER_2_0_SCHEMA.validate(specRoot);
        final List<Violation> errors = new ArrayList<>();
        final List<Violation> warnings = new ArrayList<>();
        for (final ProcessingMessage message : report) {
            final boolean added = append(errors, message, Optional.of("error"));
            if (!added) {
                append(warnings, message, Optional.empty());
            }
        }

        return new SwaggerModelInfo.Builder().errors(errors).warnings(warnings).model(model).resolvedSpecification(specification)
            .build();

    } catch (IOException | ProcessingException ex) {
        LOG.error("Unable to load the schema file embedded in the artifact", ex);
        return new SwaggerModelInfo.Builder().addError(new Violation.Builder().error("error").property("")
            .message("Unable to load the swagger schema file embedded in the artifact").build()).build();
    }
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:23,代碼來源:SwaggerHelper.java

示例2: checkSchema

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
private void checkSchema(File output)
{
    try
    {
        JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
        URL schemaPath = getClass().getResource("/swagger-schema.json");
        JsonSchema schema = factory.getJsonSchema(schemaPath.toString());
        JsonNode json = JsonLoader.fromFile(output);

        ProcessingReport report = schema.validate(json);
        System.out.println(report);
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
開發者ID:mauriciotogneri,項目名稱:stewie,代碼行數:18,代碼來源:Stewie.java

示例3: isValid

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
public static boolean isValid(String json, String schema) throws Exception {
    JsonNode schemaNode = JsonLoader.fromString(schema);       
    JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
    JsonSchema jsonSchema = factory.getJsonSchema(schemaNode); 
    JsonNode jsonNode = JsonLoader.fromString(json);
    ProcessingReport report = jsonSchema.validate(jsonNode);
    logger.debug("report: {}", report);
    return report.isSuccess();
}
 
開發者ID:intuit,項目名稱:karate,代碼行數:10,代碼來源:SchemaUtils.java

示例4: isValid

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
public boolean isValid(JsonNode jsonNode) {
    final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
    log.verboseOutput("Checking against schema. Available at 'https://raw.githubusercontent.com/pivio/pivio-client/master/src/main/resources/pivio-schema.json'.", configuration.isVerbose());
    try {
        String schemaContent = readFromJARFile("/pivio-schema.json");
        JsonNode schemaNode = new ObjectMapper().readTree(schemaContent);
        final JsonSchema jsonSchema = factory.getJsonSchema(schemaNode);
        ProcessingReport processingReport = jsonSchema.validate(jsonNode);
        for (ProcessingMessage processingMessage : processingReport) {
            String pointer = processingMessage.asJson().get("instance").get("pointer").asText();
            log.output(pointer + " : " + processingMessage.getMessage());
        }
        return processingReport.isSuccess();
    } catch (ProcessingException | IOException e ) {
        log.output("Error processing Json. "+e.getMessage());
        return false;
    }
}
 
開發者ID:pivio,項目名稱:pivio-client,代碼行數:19,代碼來源:SchemaValidator.java

示例5: testValidateWithValidBuilder

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
@Test
public void testValidateWithValidBuilder() throws Exception {
    DataExportSpecificationBuilder spec = DataExportSpecificationBuilder.withGeoJsonExporter().addSubjectSpecification(
            new SubjectSpecificationBuilder("uk.gov.ons", "lsoa").setMatcher("label", "E01002766"))
            .addSubjectSpecification(
                    new SubjectSpecificationBuilder("uk.gov.ons", "localAuthority").setMatcher("label", "E08000035"))
            .addDatasourceSpecification("uk.org.tombolo.importer.ons.CensusImporter", "qs103ew", "")
            .addFieldSpecification(
                    FieldBuilder.wrapperField("attributes", Arrays.asList(
                            FieldBuilder.fractionOfTotal("percentage_under_1_years_old_label")
                                    .addDividendAttribute("uk.gov.ons", "CL_0000053_2") // number under one year old
                                    .setDivisorAttribute("uk.gov.ons", "CL_0000053_1") // total population
                    ))
            );
    ProcessingReport report = DataExportRecipeValidator.validate(new StringReader(spec.toJSONString()));
    assertTrue("Spec is valid", report.isSuccess());
}
 
開發者ID:FutureCitiesCatapult,項目名稱:TomboloDigitalConnector,代碼行數:18,代碼來源:DataExportRecipeValidatorTest.java

示例6: testDefaultConfig

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
@Test
public final void testDefaultConfig()
throws Exception {
	final ObjectMapper m = new ObjectMapper()
		.configure(JsonParser.Feature.ALLOW_COMMENTS, true)
		.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
	final JsonNode jsonInput = m.readTree(
		Paths.get(PathUtil.getBaseDir(), "config", "defaults.json").toFile()
	);
	final JsonNode jsonSchema = m.readTree(
		Paths.get(PathUtil.getBaseDir(), "config", "config-schema.json").toFile()
	);
	final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
	final JsonValidator validator = factory.getValidator();
	final ProcessingReport report = validator.validate(jsonSchema, jsonInput);
	assertTrue(report.toString(), report.isSuccess());
}
 
開發者ID:emc-mongoose,項目名稱:mongoose-base,代碼行數:18,代碼來源:ValidateConfigTest.java

示例7: doValidate

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
private static void doValidate(final Map<String, JsonNode> schemas,
                               final int i)
        throws ProcessingException
{
    String name;
    JsonNode value;
    ProcessingReport report;

    for (final Map.Entry<String, JsonNode> entry: schemas.entrySet()) {
        name = entry.getKey();
        value = entry.getValue();
        report = SCHEMA.validate(value);
        if (!report.isSuccess()) {
            System.err.println("ERROR: schema " + name + " did not "
                    + "validate (iteration " + i + ')');
            System.exit(1);
        }
    }
}
 
開發者ID:networknt,項目名稱:json-schema-validator-perftest,代碼行數:20,代碼來源:FgePerf.java

示例8: execute

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
@Override
protected ExecuteResult execute(final WebServiceConnector connector) {
    final String body = connector.getBody();
    final ObjectMapper mapper = new ObjectMapper();

    try {
        final JsonNode obj = mapper.readTree(body);
        final JsonNode schema = mapper.readTree(this.schema);

        final ProcessingReport report = JsonSchemaFactory.byDefault()
                .getJsonSchema(schema)
                .validate(obj);

        return report.isSuccess() ? getSuccessOutput() : getFailedOutput();
    } catch (IOException | ProcessingException e) {
        return getFailedOutput();
    }
}
 
開發者ID:LearnLib,項目名稱:alex,代碼行數:19,代碼來源:ValidateJsonAction.java

示例9: validate

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
public ValidationErrors validate(String schema, String requestBody) {
    ValidationErrors errors = new ValidationErrors();

    try {
        JsonNode schemaNode = JsonLoader.fromString(schema);
        JsonNode dataNode = JsonLoader.fromString(requestBody);

        ProcessingReport report = JsonSchemaFactory.byDefault().getJsonSchema(schemaNode).validate(dataNode);

        if (!report.isSuccess())
            report.iterator().forEachRemaining(m -> errors.addMessage("[ %s ] [ body ] %s", bodyType, m.getMessage()));
    } catch (Exception e) {
        errors.addMessage("[ %s ] [ body ] Unexpected error of [ %s ] while validating JSON content", bodyType, e.getMessage());
    }
    return errors;
}
 
開發者ID:ozwolf-software,項目名稱:raml-mock-server,代碼行數:17,代碼來源:JsonContentValidator.java

示例10: validate

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
public void validate(JsonNode node) throws InvalidJsonException {
	ProcessingReport report = null;
	try {
		report = getSchema().validate(node);
	}
	catch (Throwable ex) {
		throw new InvalidJsonException("Could not validate JSON against schema" + getDescriptionAppendable(), ex);
	}
	if (!report.isSuccess()) {

		StringBuilder builder = new StringBuilder();
		builder.append("Could not validate JSON against schema");
		builder.append(getDescriptionAppendable());
		builder.append(":");
		builder.append(LS);
		List<ProcessingMessage> messages = Lists.newArrayList(report);
		for (int i = 0; i < messages.size(); i++) {
			builder.append("- ");
			builder.append(messages.get(i).getMessage());
			builder.append(i == (messages.size() - 1) ? EMPTY : LS);
		}
		throw new InvalidJsonException(builder.toString());
	}
}
 
開發者ID:galan,項目名稱:verjson,代碼行數:25,代碼來源:Validation.java

示例11: assertMatchesJsonSchema

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
private void assertMatchesJsonSchema(final String json) {
    try {
        final ObjectNode rootNode = (ObjectNode) JsonLoader.fromString(json);
        final ObjectNode contextNode = (ObjectNode) rootNode.get("context");
        if (contextNode != null) {
            contextNode.remove("logger");
            contextNode.remove("MDC_KEY");
            contextNode.remove("CONTEXT_KEY1");
            contextNode.remove("CONTEXT_KEY2");
            contextNode.remove("CONTEXT_KEY3");
            contextNode.remove("CONTEXT_KEY4");
            contextNode.remove("CONTEXT_KEY5");
            contextNode.remove("CONTEXT_KEY6");
        }
        final ProcessingReport report = _validator.validate(STENO_SCHEMA, rootNode);
        Assert.assertTrue(report.toString(), report.isSuccess());
    } catch (final IOException | ProcessingException e) {
        Assert.fail("Failed with exception: " + e);
    }
}
 
開發者ID:ArpNetworking,項目名稱:logback-steno,代碼行數:21,代碼來源:StenoEncoderTest.java

示例12: validatingRead

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public GraphsWithValidation validatingRead(File input) throws IOException {
    if (input == null) throw new NullPointerException("input cannot be null");
    if (!input.exists()) throw new FileNotFoundException("input does not exist");
    if (!input.exists() || !input.canRead())
        throw new FileNotFoundException("input does not exist");

    JsonNode json = _readJSON(new FileInputStream(input));

    ProcessingReport report = _validate(json);

    if (report.isSuccess()) {
        return new GraphsWithValidation(_readGraph(json), report);
    }
    return new GraphsWithValidation(new Graph[0], report);
}
 
開發者ID:jsongraph,項目名稱:jgf-app,代碼行數:20,代碼來源:GraphReaderImpl.java

示例13: _validate

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
protected ProcessingReport _validate(JsonNode json) throws IOException {
    final JsonNode belSchema = JsonLoader.fromResource("/bel-json-graph.schema.json");
    final JsonSchemaFactory factory = JsonSchemaFactory.byDefault();
    final JsonSchema schema;
    try {
        schema = factory.getJsonSchema(belSchema);
        return schema.validate(json, true);
    } catch (ProcessingException e) {
        throw new IOException(e);
    }
}
 
開發者ID:jsongraph,項目名稱:jgf-app,代碼行數:12,代碼來源:GraphReaderImpl.java

示例14: testReadSingleGraphWithValidation

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
@Test
public void testReadSingleGraphWithValidation() throws IOException {
    InputStream stream = this.getClass().getClassLoader().getResourceAsStream("testData/jgf/single_graph.jgf");
    GraphReader reader = new GraphReaderImpl();
    GraphsWithValidation gv = reader.validatingRead(stream);

    // check validation
    assertThat(gv, is(notNullValue()));
    ProcessingReport validation = gv.getValidationReport();
    assertThat(validation, is(notNullValue()));
    assertThat(validation.isSuccess(), is(true));
    assertThat(validation, is(emptyIterable()));

    // check graph
    Graph[] graphs = gv.getGraphs();
    assertThat(graphs, arrayWithSize(1));
    assertThat(graphs[0], is(notNullValue()));
}
 
開發者ID:jsongraph,項目名稱:jgf-app,代碼行數:19,代碼來源:GraphReaderImplTest.java

示例15: testReadMultipleGraphsWithValidation

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入依賴的package包/類
@Test
public void testReadMultipleGraphsWithValidation() throws IOException {
    InputStream stream = this.getClass().getClassLoader().getResourceAsStream("testData/jgf/multiple_graphs.jgf");
    GraphReader reader = new GraphReaderImpl();
    GraphsWithValidation gv = reader.validatingRead(stream);

    // check validation
    assertThat(gv, is(notNullValue()));
    ProcessingReport validation = gv.getValidationReport();
    assertThat(validation, is(notNullValue()));
    assertThat(validation, is(notNullValue()));
    assertThat(validation.isSuccess(), is(true));
    assertThat(validation, is(emptyIterable()));

    // check graph
    Graph[] graphs = gv.getGraphs();
    assertThat(graphs, arrayWithSize(2));
}
 
開發者ID:jsongraph,項目名稱:jgf-app,代碼行數:19,代碼來源:GraphReaderImplTest.java


注:本文中的com.github.fge.jsonschema.core.report.ProcessingReport類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。