Package com.linkedin.data.schema.validation

Examples of com.linkedin.data.schema.validation.ValidationOptions


    return _infoMap;
  }

  private void runCheck()
  {
    final ValidationOptions valOptions = new ValidationOptions();
    boolean valResult = validateData(_prevSchema.data(), _prevSchema.schema(), valOptions);
    valResult &= validateData(_currSchema.data(), _currSchema.schema(), valOptions);
    if (valResult)
    {
      checkResourceSchema(_prevSchema, _currSchema);
View Full Code Here


    int exitCode = 0;
    for (File sourceFile : sourceFiles)
    {
      try
      {
        final ValidationOptions val = new ValidationOptions();
        val.setAvroUnionMode(isAvroMode);

        final SchemaParser schemaParser = new SchemaParser();
        schemaParser.setValidationOptions(val);

        schemaParser.parse(new FileInputStream(sourceFile));
View Full Code Here

                                               Map<String, JClass> assocKeyTypes,
                                               Map<String, List<String>> pathToAssocKeys)
          throws JClassAlreadyExistsException, IOException
  {
    ValidationResult validationResult = ValidateDataAgainstSchema.validate(resource.data(), resource.schema(),
                                                                           new ValidationOptions(
                                                                                           RequiredMode.MUST_BE_PRESENT));
    if (!validationResult.isValid())
    {
        throw new IllegalArgumentException(String.format(
                "Resource validation error.  Resource File '%s', Error Details '%s'",
View Full Code Here

  @Test
  public void testRecordTemplatesAfterFixup()
  {
    RecordTemplateWithDefaultValue actual = new RecordTemplateWithDefaultValue().setId(1L);
    RecordTemplateWithDefaultValue expected = new RecordTemplateWithDefaultValue().setId(1L).setMessage("message");
    ValidationOptions validationOptions = new ValidationOptions(RequiredMode.FIXUP_ABSENT_WITH_DEFAULT,
                                                                CoercionMode.STRING_TO_PRIMITIVE);

    try
    {
      DataAssert.assertRecordTemplateDataEqual(actual, expected, validationOptions);
View Full Code Here

    }
    greeting.setId(createdId);
    Request<Greeting> getRequest = builders.get().id(createdId).build();
    Greeting getReturnedGreeting = REST_CLIENT.sendRequest(getRequest).getResponse().getEntity();
    ValidateDataAgainstSchema.validate(getReturnedGreeting.data(), getReturnedGreeting.schema(),
                                       new ValidationOptions());
    assertEquals(getReturnedGreeting, greeting);
    deleteAndVerifyTestData(builders, createdId);
    verifyFilters(tone, responseFilter);
  }
View Full Code Here

      {
        if ((tests & SCHEMA_VALIDATOR) != 0)
        {
          // validate using ValidateDataWithSchema
          VisitedTrackingValidator visitedValidator = new VisitedTrackingValidator(annotationValidator);
          ValidationOptions validationOptions = new ValidationOptions(RequiredMode.CAN_BE_ABSENT_IF_HAS_DEFAULT, CoercionMode.NORMAL);
          ValidationResult result = ValidateDataAgainstSchema.validate(value.copy(), schema, validationOptions, visitedValidator);
          checkValidationResult(value, result, row, visitedValidator);
        }

        if ((tests & OBJECT_VALIDATOR) != 0)
View Full Code Here

      if (debug) out.println(dataSchemaAnnotationValidator);
      dataSchemaAnnotationValidator.setDebugMode(debug);

      OrderValidator._orderList.clear();

      ValidationOptions validationOptions = new ValidationOptions();
      ValidationResult validationResult =
        ValidateDataAgainstSchema.validate(dataMap, schema, validationOptions, dataSchemaAnnotationValidator);
      assertTrue(validationResult.isValid());

      if (debug) out.println(validationResult.getMessages());
View Full Code Here

        }
      };

    final boolean debug = false;

    ValidationOptions options = new ValidationOptions();

    for (Object[] row : inputs)
    {
      int i = 0;
      DataSchema schema = (DataSchema) row[i++];
View Full Code Here

        "      \"com.linkedin.Cat\" : { \"c\" : 1 }\n" +
        "    }\n" +
        "  }\n" +
        "}",
        false,
        new ValidationOptions(RequiredMode.IGNORE, CoercionMode.NORMAL),
        ResultFlag.VALID,
        ResultFlag.HAS_FIX,
        ResultFlag.NOT_HAS_FIXUP_READONLY_ERROR,
        new String[] { },
      },
      {
        ANYRECORDCLIENT_SCHEMA,
        "{" +
        "  \"required\" : {\n" +
        "    \"com.linkedin.data.schema.validator.AnyRecord\" : {\n" +
        "      \"com.linkedin.Cat\" : { \"c\" : 1 }\n" +
        "    }\n" +
        "  }\n" +
        "}",
        true,
        new ValidationOptions(RequiredMode.IGNORE, CoercionMode.NORMAL),
        ResultFlag.NOT_VALID,
        ResultFlag.HAS_FIX,
        ResultFlag.HAS_FIXUP_READONLY_ERROR,
        new String[] { "ERROR""/required/com.linkedin.data.schema.validator.AnyRecord/com.linkedin.Cat/c", "cannot be fixed because DataMap backing com.linkedin.Cat type is read-only" },
      }
    };

    final boolean debug = false;

    final AnyRecordValidator.Parameter anyRecordValidatorParameter = new AnyRecordValidator.Parameter(true, _resolver);

    for (Object[] row : inputs)
    {
      int i = 0;
      DataSchema schema = (DataSchema) row[i++];
      DataMap object = TestUtil.dataMapFromString((String) row[i++]);
      boolean makeReadOnly = (Boolean) row[i++];
      ValidationOptions options = (ValidationOptions) row[i++];

      if (makeReadOnly)
      {
        object.makeReadOnly();
      }
View Full Code Here

      {
        final DataTemplate<?> itemsElem = DataTemplateUtil.wrap(paramData, param.getItemType().asSubclass(DataTemplate.class));

        ValidateDataAgainstSchema.validate(itemsElem.data(),
                                           itemsElem.schema(),
                                           new ValidationOptions(RequiredMode.CAN_BE_ABSENT_IF_HAS_DEFAULT,
                                                                 CoercionMode.STRING_TO_PRIMITIVE));

        Array.set(convertedValue, j++, itemsElem);
      }
    }
View Full Code Here

TOP

Related Classes of com.linkedin.data.schema.validation.ValidationOptions

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.