Skip to content

Commit

Permalink
refactor: remove Cloud Database dependency from OrbClientImpl and cle…
Browse files Browse the repository at this point in the history
…an up Orb Customer initialization (#13621)
  • Loading branch information
pmossman committed Aug 26, 2024
1 parent d923f5a commit 0280b62
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ properties:
organizationId:
type: string
format: uuid
createdAt:
type: integer
format: int64
updatedAt:
type: integer
format: int64
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,19 @@ void testGetWorkspaceBySlug() throws IOException {
final Optional<StandardWorkspace> retrievedTombstonedWorkspace = configRepository.getWorkspaceBySlugOptional(tombstonedWorkspace.getSlug(), true);

assertTrue(retrievedWorkspace.isPresent());
assertEquals(workspace, retrievedWorkspace.get());

assertThat(retrievedWorkspace.get())
.usingRecursiveComparison()
.ignoringFields("createdAt", "updatedAt")
.isEqualTo(workspace);

assertFalse(retrievedTombstonedWorkspaceNoTombstone.isPresent());
assertTrue(retrievedTombstonedWorkspace.isPresent());

assertEquals(tombstonedWorkspace, retrievedTombstonedWorkspace.get());
assertThat(retrievedTombstonedWorkspace.get())
.usingRecursiveComparison()
.ignoringFields("createdAt", "updatedAt")
.isEqualTo(tombstonedWorkspace);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package io.airbyte.config.persistence;

import static io.airbyte.config.persistence.OrganizationPersistence.DEFAULT_ORGANIZATION_ID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -222,7 +223,21 @@ void assertReturnsWorkspace(final StandardWorkspace workspace) throws ConfigNotF
expectedWorkspace.withTombstone(false);
}

assertEquals(workspace, configRepository.getStandardWorkspaceNoSecrets(WORKSPACE_ID, true));
assertWorkspaceEquals(expectedWorkspace, configRepository.getStandardWorkspaceNoSecrets(WORKSPACE_ID, true));
}

private void assertWorkspaceEquals(final StandardWorkspace expectedWorkspace, final StandardWorkspace actualWorkspace) {
assertThat(actualWorkspace)
.usingRecursiveComparison()
.ignoringFields("createdAt", "updatedAt")
.isEqualTo(expectedWorkspace);
}

private void assertWorkspacesEqual(final Set<StandardWorkspace> expectedWorkspaces, final Set<StandardWorkspace> actualWorkspaces) {
assertThat(actualWorkspaces)
.usingRecursiveComparison()
.ignoringFields("createdAt", "updatedAt")
.isEqualTo(expectedWorkspaces);
}

// @ParameterizedTest
Expand Down Expand Up @@ -312,7 +327,7 @@ void testListWorkspacesInOrgNoKeyword() throws Exception {
assertReturnsWorkspace(createBaseStandardWorkspace().withTombstone(false));

assertEquals(1, workspaces.size());
assertEquals(workspace, workspaces.get(0));
assertWorkspaceEquals(workspace, workspaces.get(0));
}

@Test
Expand All @@ -331,7 +346,7 @@ void testListWorkspacesInOrgWithPagination() throws Exception {
new ResourcesByOrganizationQueryPaginated(MockData.ORGANIZATION_ID_1, false, 1, 0), Optional.empty());

assertEquals(1, workspaces.size());
assertEquals(workspace, workspaces.get(0));
assertWorkspaceEquals(workspace, workspaces.get(0));
}

@Test
Expand All @@ -350,7 +365,7 @@ void testListWorkspacesInOrgWithKeyword() throws Exception {
new ResourcesByOrganizationQueryPaginated(MockData.ORGANIZATION_ID_1, false, 10, 0), Optional.of("keyword"));

assertEquals(1, workspaces.size());
assertEquals(workspace, workspaces.get(0));
assertWorkspaceEquals(workspace, workspaces.get(0));
}

@Test
Expand Down Expand Up @@ -379,7 +394,7 @@ void testGetDefaultWorkspaceForOrganization() throws JsonValidationException, IO

final StandardWorkspace actualWorkspace = workspacePersistence.getDefaultWorkspaceForOrganization(MockData.ORGANIZATION_ID_1);

assertEquals(expectedWorkspace, actualWorkspace);
assertWorkspaceEquals(expectedWorkspace, actualWorkspace);
}

@ParameterizedTest
Expand Down Expand Up @@ -469,7 +484,7 @@ void testListWorkspacesByUserIdWithKeywordWithPagination() throws Exception {
final Set<StandardWorkspace> expectedWorkspaces = Set.of(workspace1, workspace2);
final Set<StandardWorkspace> actualWorkspaces = new HashSet<>(workspaces);

assertEquals(expectedWorkspaces, actualWorkspaces);
assertWorkspacesEqual(expectedWorkspaces, actualWorkspaces);
}

@Test
Expand Down Expand Up @@ -534,7 +549,7 @@ void testListWorkspacesByUserIdWithoutKeywordWithoutPagination() throws Exceptio

final Set<StandardWorkspace> actualWorkspaces = new HashSet<>(workspacePersistence.listActiveWorkspacesByUserId(userId, Optional.empty()));

assertEquals(expectedWorkspaces, actualWorkspaces);
assertWorkspacesEqual(expectedWorkspaces, actualWorkspaces);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ public static StandardWorkspace buildStandardWorkspace(final Record record) {
Enums.toEnum(record.get(WORKSPACE.GEOGRAPHY, String.class), Geography.class).orElseThrow())
.withWebhookOperationConfigs(record.get(WORKSPACE.WEBHOOK_OPERATION_CONFIGS) == null ? null
: Jsons.deserialize(record.get(WORKSPACE.WEBHOOK_OPERATION_CONFIGS).data()))
.withOrganizationId(record.get(WORKSPACE.ORGANIZATION_ID));
.withOrganizationId(record.get(WORKSPACE.ORGANIZATION_ID))
.withCreatedAt(record.get(WORKSPACE.CREATED_AT, OffsetDateTime.class).toEpochSecond())
.withUpdatedAt(record.get(WORKSPACE.UPDATED_AT, OffsetDateTime.class).toEpochSecond());
}

/**
Expand Down

0 comments on commit 0280b62

Please sign in to comment.