@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SchemaMetadata that = (SchemaMetadata) o; if (evolve != that.evolve) return false; if (type != null ? !type.equals(that.type) : that.type != null) return false; if (schemaGroup != null ? !schemaGroup.equals(that.schemaGroup) : that.schemaGroup != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (description != null ? !description.equals(that.description) : that.description != null) return false; if (getValidationLevel() != null ? !getValidationLevel().equals(that.getValidationLevel()) : that.getValidationLevel() != null) return false; return getCompatibility() == that.getCompatibility(); }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SchemaMetadata that = (SchemaMetadata) o; if (evolve != that.evolve) return false; if (type != null ? !type.equals(that.type) : that.type != null) return false; if (schemaGroup != null ? !schemaGroup.equals(that.schemaGroup) : that.schemaGroup != null) return false; if (name != null ? !name.equals(that.name) : that.name != null) return false; if (description != null ? !description.equals(that.description) : that.description != null) return false; if (getValidationLevel() != null ? !getValidationLevel().equals(that.getValidationLevel()) : that.getValidationLevel() != null) return false; return getCompatibility() == that.getCompatibility(); }
@Override public int hashCode() { int result = type != null ? type.hashCode() : 0; result = 31 * result + (schemaGroup != null ? schemaGroup.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (description != null ? description.hashCode() : 0); result = 31 * result + (getCompatibility() != null ? getCompatibility().hashCode() : 0); result = 31 * result + (getValidationLevel() != null ? getValidationLevel().hashCode() : 0); result = 31 * result + (evolve ? 1 : 0); return result; }
@Override public int hashCode() { int result = type != null ? type.hashCode() : 0; result = 31 * result + (schemaGroup != null ? schemaGroup.hashCode() : 0); result = 31 * result + (name != null ? name.hashCode() : 0); result = 31 * result + (description != null ? description.hashCode() : 0); result = 31 * result + (getCompatibility() != null ? getCompatibility().hashCode() : 0); result = 31 * result + (getValidationLevel() != null ? getValidationLevel().hashCode() : 0); result = 31 * result + (evolve ? 1 : 0); return result; }
public Builder(SchemaMetadata schemaMetadata) { name = schemaMetadata.getName(); type = schemaMetadata.getType(); schemaGroup = schemaMetadata.getSchemaGroup(); description = schemaMetadata.getDescription(); compatibility = schemaMetadata.getCompatibility(); validationLevel = schemaMetadata.getValidationLevel(); evolve = schemaMetadata.isEvolve(); }
public Builder(SchemaMetadata schemaMetadata) { name = schemaMetadata.getName(); type = schemaMetadata.getType(); schemaGroup = schemaMetadata.getSchemaGroup(); description = schemaMetadata.getDescription(); compatibility = schemaMetadata.getCompatibility(); validationLevel = schemaMetadata.getValidationLevel(); evolve = schemaMetadata.isEvolve(); }
SchemaMetadata schemaMetadata = schemaMetadataInfo.getSchemaMetadata(); String schemaName = schemaMetadata.getName(); SchemaValidationLevel validationLevel = schemaMetadata.getValidationLevel();
SchemaMetadata schemaMetadata = schemaMetadataInfo.getSchemaMetadata(); String schemaName = schemaMetadata.getName(); SchemaValidationLevel validationLevel = schemaMetadata.getValidationLevel();
public static SchemaMetadataStorable updateSchemaMetadata(SchemaMetadataStorable schemaMetadataStorable, SchemaMetadata schemaMetadata) { schemaMetadataStorable.setType(schemaMetadata.getType()); schemaMetadataStorable.setSchemaGroup(schemaMetadata.getSchemaGroup()); schemaMetadataStorable.setName(schemaMetadata.getName()); schemaMetadataStorable.setDescription(schemaMetadata.getDescription()); schemaMetadataStorable.setCompatibility(schemaMetadata.getCompatibility()); schemaMetadataStorable.setValidationLevel(schemaMetadata.getValidationLevel()); schemaMetadataStorable.setEvolve(schemaMetadata.isEvolve()); return schemaMetadataStorable; }
SchemaValidationLevel validationLevel = schemaMetadata.getValidationLevel(); CompatibilityResult compatibilityResult = null; switch (validationLevel) {
@Test public void testValidationLevels() throws Exception { SchemaMetadata schemaMetadata = createSchemaMetadata(TEST_NAME_RULE.getMethodName(), SchemaCompatibility.BOTH); String schemaName = schemaMetadata.getName(); Long id = SCHEMA_REGISTRY_CLIENT.registerSchemaMetadata(schemaMetadata); SCHEMA_REGISTRY_CLIENT.addSchemaVersion(schemaName, new SchemaVersion(AvroSchemaRegistryClientUtil.getSchema("/schema-1.avsc"), "Initial version of the schema")); SCHEMA_REGISTRY_CLIENT.addSchemaVersion(schemaName, new SchemaVersion(AvroSchemaRegistryClientUtil.getSchema("/schema-2.avsc"), "Second version of the schema")); SCHEMA_REGISTRY_CLIENT.addSchemaVersion(schemaName, new SchemaVersion(AvroSchemaRegistryClientUtil.getSchema("/schema-3.avsc"), "Third version of the schema, removes name field")); try { SCHEMA_REGISTRY_CLIENT.addSchemaVersion(schemaName, new SchemaVersion(AvroSchemaRegistryClientUtil.getSchema("/schema-4.avsc"), "Forth version of the schema, adds back name field, but different type")); Assert.fail("Should throw IncompatibleSchemaException as check against all schema's would find name field is not compatible with v1 and v2"); } catch (IncompatibleSchemaException ise) { //expected } SchemaMetadata currentSchemaMetadata = SCHEMA_REGISTRY_CLIENT.getSchemaMetadataInfo(schemaName) .getSchemaMetadata(); SchemaMetadata schemaMetadataToUpdateTo = new SchemaMetadata.Builder(currentSchemaMetadata).validationLevel(SchemaValidationLevel.LATEST) .build(); SchemaMetadataInfo updatedSchemaMetadata = SCHEMA_REGISTRY_CLIENT.updateSchemaMetadata(schemaName, schemaMetadataToUpdateTo); Assert.assertEquals(SchemaValidationLevel.LATEST, updatedSchemaMetadata.getSchemaMetadata() .getValidationLevel()); try { SCHEMA_REGISTRY_CLIENT.addSchemaVersion(schemaName, new SchemaVersion(AvroSchemaRegistryClientUtil.getSchema("/schema-4.avsc"), "Forth version of the schema, adds back name field, but different type")); } catch (IncompatibleSchemaException ise) { Assert.fail("Should not throw IncompatibleSchemaException as check against only latest schema as such should ignore v1 and v2"); } }