InternalSchemaMetadataPayloadCodec { static InternalSchemaMetadata decode(VersionedInternalSchemaMetadata versionedInternalSchemaMetadata) { return tryDecode(versionedInternalSchemaMetadata) .orElseThrow(() -> new SafeIllegalStateException("Could not decode persisted internal schema metadata -" + " unrecognized version. This may occur transiently during upgrades, but if it persists please" + " contact support.", SafeArg.of("internalSchemaMetadata", versionedInternalSchemaMetadata), SafeArg.of("knownVersions", SUPPORTED_DECODERS.keySet()))); } private  InternalSchemaMetadataPayloadCodec();  static final int LATEST_VERSION; }
@Test public void cannotDeserializeUnknownVersionOfMetadata() { assertThatThrownBy(() -> InternalSchemaMetadataPayloadCodec.decode(ImmutableVersionedInternalSchemaMetadata.builder() .version(8377466) .payload(new byte[] {1, 2, 3}) .build())) .isInstanceOf(IllegalStateException.class) .hasMessageContaining("Could not decode persisted internal schema metadata - unrecognized version."); }
@Test public void canDeserializeV1Metadata() throws URISyntaxException, IOException { String resourcePath = getResourcePath("internalschema-persistence/versioned-metadata-v1-1.json"); byte[] bytes = Files.readAllBytes(Paths.get(resourcePath)); VersionedInternalSchemaMetadata versionedInternalSchemaMetadata = ObjectMappers.newServerObjectMapper().readValue(bytes, VersionedInternalSchemaMetadata.class); assertThat(InternalSchemaMetadataPayloadCodec.decode(versionedInternalSchemaMetadata)) .isEqualTo(INTERNAL_SCHEMA_METADATA); }