Skip to content

Commit

Permalink
Add an explicit v0 version of the protocol (#16797)
Browse files Browse the repository at this point in the history
  • Loading branch information
gosusnp committed Sep 21, 2022
1 parent c83a595 commit bded0ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

package io.airbyte.protocol.models;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import io.airbyte.commons.json.Jsons;
import io.airbyte.protocol.models.AirbyteMessage.Type;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
Expand Down Expand Up @@ -33,4 +36,16 @@ void testJsonSchemaType() {
}
}

@Test
void testVersionedObjectsAccessibility() {
final var message = new io.airbyte.protocol.models.AirbyteMessage()
.withType(Type.SPEC);
final var messageV0 = new io.airbyte.protocol.models.v0.AirbyteMessage()
.withType(io.airbyte.protocol.models.v0.AirbyteMessage.Type.SPEC);

// This only works as long as the default version and v0 are equal
final var deserializedMessage = Jsons.deserialize(Jsons.serialize(message), io.airbyte.protocol.models.v0.AirbyteMessage.class);
assertEquals(messageV0, deserializedMessage);
}

}

0 comments on commit bded0ac

Please sign in to comment.