Skip to content

Commit

Permalink
pmd
Browse files Browse the repository at this point in the history
  • Loading branch information
alovew committed Oct 10, 2022
1 parent 87ca87a commit cb3639b
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class CatalogHelpersTest {
private static final String SALES = "sales";
private static final String COMPANIES_VALID = "companies_schema.json";
private static final String COMPANIES_INVALID = "companies_schema_invalid.json";
private static final String VALID_SCHEMA_JSON = "valid_schema.json";

@Test
void testFieldToJsonSchema() {
Expand Down Expand Up @@ -95,7 +96,7 @@ void testGetTopLevelFieldNames() {

@Test
void testGetFieldNames() throws IOException {
final JsonNode node = Jsons.deserialize(MoreResources.readResource("valid_schema.json"));
final JsonNode node = Jsons.deserialize(MoreResources.readResource(VALID_SCHEMA_JSON));
final Set<String> actualFieldNames = CatalogHelpers.getAllFieldNames(node);
final List<String> expectedFieldNames =
List.of("id", CAD, "DKK", "HKD", "HUF", "ISK", "PHP", DATE, "nestedkey", "somekey", "something", "something2", "文", SOME_ARRAY, ITEMS,
Expand All @@ -107,7 +108,7 @@ void testGetFieldNames() throws IOException {

@Test
void testGetCatalogDiff() throws IOException {
final JsonNode schema1 = Jsons.deserialize(MoreResources.readResource("valid_schema.json"));
final JsonNode schema1 = Jsons.deserialize(MoreResources.readResource(VALID_SCHEMA_JSON));
final JsonNode schema2 = Jsons.deserialize(MoreResources.readResource("valid_schema2.json"));
final AirbyteCatalog catalog1 = new AirbyteCatalog().withStreams(List.of(
new AirbyteStream().withName(USERS).withJsonSchema(schema1),
Expand Down Expand Up @@ -236,7 +237,7 @@ void testGetCatalogDiffWithBothInvalidSchema() throws IOException {

@Test
void testCatalogDiffWithBreakingChanges() throws IOException {
final JsonNode schema1 = Jsons.deserialize(MoreResources.readResource("valid_schema.json"));
final JsonNode schema1 = Jsons.deserialize(MoreResources.readResource(VALID_SCHEMA_JSON));
final JsonNode breakingSchema = Jsons.deserialize(MoreResources.readResource("breaking_change_schema.json"));
final AirbyteCatalog catalog1 = new AirbyteCatalog().withStreams(List.of(
new AirbyteStream().withName(USERS).withJsonSchema(schema1)));
Expand All @@ -260,7 +261,7 @@ void testCatalogDiffWithBreakingChanges() throws IOException {

@Test
void testCatalogDiffWithoutStreamConfig() throws IOException {
final JsonNode schema1 = Jsons.deserialize(MoreResources.readResource("valid_schema.json"));
final JsonNode schema1 = Jsons.deserialize(MoreResources.readResource(VALID_SCHEMA_JSON));
final JsonNode breakingSchema = Jsons.deserialize(MoreResources.readResource("breaking_change_schema.json"));
final AirbyteCatalog catalog1 = new AirbyteCatalog().withStreams(List.of(
new AirbyteStream().withName(USERS).withJsonSchema(schema1)));
Expand All @@ -274,11 +275,12 @@ void testCatalogDiffWithoutStreamConfig() throws IOException {
final Set<StreamTransform> diff = CatalogHelpers.getCatalogDiff(catalog1, catalog2, configuredAirbyteCatalog);

final List<StreamTransform> expectedDiff = Stream.of(
StreamTransform.createUpdateStreamTransform(new StreamDescriptor().withName(USERS), new UpdateStreamTransform(Set.of(
FieldTransform.createRemoveFieldTransform(List.of(DATE), schema1.get(PROPERTIES).get(DATE), false),
FieldTransform.createRemoveFieldTransform(List.of("id"), schema1.get(PROPERTIES).get("id"), false)))))
StreamTransform.createUpdateStreamTransform(new StreamDescriptor().withName(USERS), new UpdateStreamTransform(Set.of(
FieldTransform.createRemoveFieldTransform(List.of(DATE), schema1.get(PROPERTIES).get(DATE), false),
FieldTransform.createRemoveFieldTransform(List.of("id"), schema1.get(PROPERTIES).get("id"), false)))))
.toList();

Assertions.assertThat(diff).containsAll(expectedDiff);
}

}

0 comments on commit cb3639b

Please sign in to comment.