Package com.github.fge.jsonschema.core.tree

Examples of com.github.fge.jsonschema.core.tree.SchemaTree


    @Test(dataProvider = "sampleData")
    public void onlyRelevantDigestsAreBuilt(final JsonNode node)
        throws ProcessingException
    {
        final NodeType type = NodeType.getNodeType(node);
        final SchemaTree tree
            = new CanonicalSchemaTree(SchemaKey.anonymousKey(), schema);
        final SchemaContext context = new SchemaContext(tree, type);
        final ProcessingReport report = mock(ProcessingReport.class);

        final SchemaDigest digest = schemaDigester.process(report, context);
View Full Code Here


    public void nonPresentKeywordDoesNotTriggerBuild()
        throws ProcessingException
    {
        final ObjectNode node = FACTORY.objectNode();
        node.put(K1, K1);
        final SchemaTree schemaTree
            = new CanonicalSchemaTree(SchemaKey.anonymousKey(), node);
        final SchemaContext context
            = new SchemaContext(schemaTree, NodeType.NULL);
        final ProcessingReport report = mock(ProcessingReport.class);
View Full Code Here

            return;

        final ObjectNode schema = FACTORY.objectNode();
        schema.put("not", FACTORY.objectNode());

        final SchemaTree tree
            = new CanonicalSchemaTree(SchemaKey.anonymousKey(), schema);
        final JsonTree instance = new SimpleJsonTree(FACTORY.nullNode());
        data = new FullData(tree, instance);
        report = mock(ProcessingReport.class);
        when(report.getLogLevel()).thenReturn(LogLevel.DEBUG);
View Full Code Here

    @Test
    public void childrenAreNotExploredByDefaultIfContainerFails()
        throws ProcessingException
    {
        final SchemaTree schema
            = new CanonicalSchemaTree(SchemaKey.anonymousKey(), RAWSCHEMA);
        final JsonTree instance = new SimpleJsonTree(RAWINSTANCE);
        final FullData data = new FullData(schema, instance);
        final ProcessingReport report = mock(ProcessingReport.class);
        processor.process(report, data);
View Full Code Here

    @Test
    public void childrenAreExploredOnDemandEvenIfContainerFails()
        throws ProcessingException
    {
        final SchemaTree schema
            = new CanonicalSchemaTree(SchemaKey.anonymousKey(), RAWSCHEMA);
        final JsonTree instance = new SimpleJsonTree(RAWINSTANCE);
        final FullData data = new FullData(schema, instance, true);
        final ProcessingReport report = mock(ProcessingReport.class);
        processor.process(report, data);
View Full Code Here

        InstantiationException
    {
        if (constructor == null)
            return;

        final SchemaTree tree = new CanonicalSchemaTree(
            SchemaKey.anonymousKey(), generateSchema());
        final JsonTree instance = new SimpleJsonTree(generateInstance());
        data = new FullData(tree, instance);
        report = mock(ProcessingReport.class);
        when(report.getLogLevel()).thenReturn(LogLevel.DEBUG);
View Full Code Here

    public void validate(final Processor<FullData, FullData> processor,
        final ProcessingReport report, final MessageBundle bundle,
        final FullData data)
        throws ProcessingException
    {
        final SchemaTree tree = data.getSchema();
        final JsonPointer schemaPointer = tree.getPointer();
        final JsonNode schemas = tree.getNode().get(keyword);
        final int size = schemas.size();
        final ObjectNode fullReport = FACTORY.objectNode();

        int nrSuccess = 0;
        ListProcessingReport subReport;
        JsonPointer ptr;
        FullData newData;

        for (int index = 0; index < size; index++) {
            subReport = new ListProcessingReport(report.getLogLevel(),
                LogLevel.FATAL);
            ptr = schemaPointer.append(JsonPointer.of(keyword, index));
            newData = data.withSchema(tree.setPointer(ptr));
            processor.process(subReport, newData);
            fullReport.put(ptr.toString(), subReport.asJson());
            if (subReport.isSuccess())
                nrSuccess++;
        }
View Full Code Here

                .putArgument("found", type)
                .putArgument("disallowed", toArrayNode(types)));
            return;
        }

        final SchemaTree tree = data.getSchema();
        final JsonPointer schemaPointer = tree.getPointer();
        final ObjectNode fullReport = FACTORY.objectNode();

        JsonPointer ptr;
        ListProcessingReport subReport;
        FullData newData;
        int nrSuccess = 0;

        for (final int index: schemas) {
            subReport = new ListProcessingReport(report.getLogLevel(),
                LogLevel.FATAL);
            ptr = schemaPointer.append(JsonPointer.of(keyword, index));
            newData = data.withSchema(tree.setPointer(ptr));
            processor.process(subReport, newData);
            fullReport.put(ptr.toString(), subReport.asJson());
            if (subReport.isSuccess())
                nrSuccess++;
        }
View Full Code Here

    public void validate(final Processor<FullData, FullData> processor,
        final ProcessingReport report, final MessageBundle bundle,
        final FullData data)
        throws ProcessingException
    {
        final SchemaTree tree = data.getSchema();
        final JsonPointer schemaPointer = tree.getPointer();
        final JsonNode schemas = tree.getNode().get(keyword);
        final int size = schemas.size();
        final ObjectNode fullReport = FACTORY.objectNode();

        int nrSuccess = 0;
        ListProcessingReport subReport;
        JsonPointer ptr;
        FullData newData;

        for (int index = 0; index < size; index++) {
            subReport = new ListProcessingReport(report.getLogLevel(),
                LogLevel.FATAL);
            ptr = schemaPointer.append(JsonPointer.of(keyword, index));
            newData = data.withSchema(tree.setPointer(ptr));
            processor.process(subReport, newData);
            fullReport.put(ptr.toString(), subReport.asJson());
            if (subReport.isSuccess())
                nrSuccess++;
        }
View Full Code Here

     * @throws NullPointerException the schema or pointer is null
     */
    JsonSchema buildJsonSchema(final JsonNode schema, final JsonPointer pointer)
        throws ProcessingException
    {
        final SchemaTree tree = loader.load(schema).setPointer(pointer);
        if (tree.getNode().isMissingNode())
            throw new JsonReferenceException(new ProcessingMessage()
                .setMessage(BUNDLE.getMessage("danglingRef")));
        return new JsonSchema(processor, tree, reportProvider);
    }
View Full Code Here

TOP

Related Classes of com.github.fge.jsonschema.core.tree.SchemaTree

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.