forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert the workspace update api to patch style (airbytehq#16739)
* convert the workspace api to patch style * check for empty email in workspace update
- Loading branch information
1 parent
ed80482
commit c0f07a8
Showing
4 changed files
with
84 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -395,6 +395,38 @@ void testUpdateWorkspaceNoNameUpdate() throws JsonValidationException, ConfigNot | |
assertEquals(expectedWorkspaceRead, actualWorkspaceRead); | ||
} | ||
|
||
@Test | ||
@DisplayName("Partial patch update should preserve unchanged fields") | ||
void testWorkspacePatchUpdate() throws JsonValidationException, ConfigNotFoundException, IOException { | ||
final String EXPECTED_NEW_EMAIL = "[email protected]"; | ||
final WorkspaceUpdate workspaceUpdate = new WorkspaceUpdate() | ||
.workspaceId(workspace.getWorkspaceId()) | ||
.anonymousDataCollection(true) | ||
.email(EXPECTED_NEW_EMAIL); | ||
|
||
final StandardWorkspace expectedWorkspace = Jsons.clone(workspace).withEmail(EXPECTED_NEW_EMAIL).withAnonymousDataCollection(true); | ||
when(configRepository.getStandardWorkspace(workspace.getWorkspaceId(), false)) | ||
.thenReturn(workspace) | ||
.thenReturn(expectedWorkspace); | ||
// The same as the original workspace, with only the email and data collection flags changed. | ||
final WorkspaceRead expectedWorkspaceRead = new WorkspaceRead() | ||
.workspaceId(workspace.getWorkspaceId()) | ||
.customerId(workspace.getCustomerId()) | ||
.email(EXPECTED_NEW_EMAIL) | ||
.name(workspace.getName()) | ||
.slug(workspace.getSlug()) | ||
.initialSetupComplete(workspace.getInitialSetupComplete()) | ||
.displaySetupWizard(workspace.getDisplaySetupWizard()) | ||
.news(workspace.getNews()) | ||
.anonymousDataCollection(true) | ||
.securityUpdates(workspace.getSecurityUpdates()) | ||
.notifications(NotificationConverter.toApiList(workspace.getNotifications())); | ||
|
||
final WorkspaceRead actualWorkspaceRead = workspacesHandler.updateWorkspace(workspaceUpdate); | ||
verify(configRepository).writeStandardWorkspace(expectedWorkspace); | ||
assertEquals(expectedWorkspaceRead, actualWorkspaceRead); | ||
} | ||
|
||
@Test | ||
void testSetFeedbackDone() throws JsonValidationException, ConfigNotFoundException, IOException { | ||
final WorkspaceGiveFeedback workspaceGiveFeedback = new WorkspaceGiveFeedback() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters