From c975dff829f2d93a14996be54475c3574010a83b Mon Sep 17 00:00:00 2001 From: Benoit Moriceau Date: Thu, 8 Dec 2022 11:51:01 -0800 Subject: [PATCH] Use existing status when no breaking change (#20253) * Use existing status when no breaking change * Fix tests * Format --- .../io/airbyte/server/handlers/SchedulerHandler.java | 2 +- .../io/airbyte/server/handlers/SchedulerHandlerTest.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/airbyte-server/src/main/java/io/airbyte/server/handlers/SchedulerHandler.java b/airbyte-server/src/main/java/io/airbyte/server/handlers/SchedulerHandler.java index bef867d6dfdb..9681f916f559 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/handlers/SchedulerHandler.java +++ b/airbyte-server/src/main/java/io/airbyte/server/handlers/SchedulerHandler.java @@ -401,7 +401,7 @@ private void discoveredSchemaWithCatalogDiff(final SourceDiscoverSchemaRead disc if (shouldDisableConnection(containsBreakingChange, connectionRead.getNonBreakingChangesPreference(), diff)) { connectionStatus = ConnectionStatus.INACTIVE; } else { - connectionStatus = ConnectionStatus.ACTIVE; + connectionStatus = connectionRead.getStatus(); } updateObject.status(connectionStatus); connectionsHandler.updateConnection(updateObject); diff --git a/airbyte-server/src/test/java/io/airbyte/server/handlers/SchedulerHandlerTest.java b/airbyte-server/src/test/java/io/airbyte/server/handlers/SchedulerHandlerTest.java index 3666e3ccc95d..5d752cb3a5e6 100644 --- a/airbyte-server/src/test/java/io/airbyte/server/handlers/SchedulerHandlerTest.java +++ b/airbyte-server/src/test/java/io/airbyte/server/handlers/SchedulerHandlerTest.java @@ -626,7 +626,7 @@ void testDiscoverSchemaFromSourceIdWithConnectionIdNonBreakingDisableConnectionP final ConnectionRead connectionRead = new ConnectionRead().syncCatalog(CatalogConverter.toApi(airbyteCatalogCurrent)).nonBreakingChangesPreference( - NonBreakingChangesPreference.DISABLE); + NonBreakingChangesPreference.DISABLE).status(ConnectionStatus.ACTIVE); when(connectionsHandler.getConnection(request.getConnectionId())).thenReturn(connectionRead); when(connectionsHandler.getDiff(any(), any(), any())).thenReturn(catalogDiff); @@ -729,7 +729,8 @@ void testDiscoverSchemaFromSourceIdWithConnectionIdBreaking() throws IOException CatalogHelpers.createAirbyteStream(SHOES, Field.of(SKU, JsonSchemaType.STRING)), CatalogHelpers.createAirbyteStream(DOGS, Field.of(NAME, JsonSchemaType.STRING)))); - final ConnectionRead connectionRead = new ConnectionRead().syncCatalog(CatalogConverter.toApi(airbyteCatalogCurrent)); + final ConnectionRead connectionRead = + new ConnectionRead().syncCatalog(CatalogConverter.toApi(airbyteCatalogCurrent)).status(ConnectionStatus.ACTIVE); when(connectionsHandler.getConnection(request.getConnectionId())).thenReturn(connectionRead); when(connectionsHandler.getDiff(any(), any(), any())).thenReturn(catalogDiff); @@ -837,7 +838,7 @@ void testDiscoverSchemaFromSourceIdWithConnectionIdNonBreakingDisableConnectionP final ConnectionRead connectionRead = new ConnectionRead().syncCatalog(CatalogConverter.toApi(airbyteCatalogCurrent)).nonBreakingChangesPreference( - NonBreakingChangesPreference.DISABLE); + NonBreakingChangesPreference.DISABLE).status(ConnectionStatus.INACTIVE); when(connectionsHandler.getConnection(request.getConnectionId())).thenReturn(connectionRead); when(connectionsHandler.getDiff(any(), any(), any())).thenReturn(catalogDiff); @@ -854,7 +855,7 @@ void testDiscoverSchemaFromSourceIdWithConnectionIdNonBreakingDisableConnectionP final SourceDiscoverSchemaRead actual = schedulerHandler.discoverSchemaForSourceFromSourceId(request); assertEquals(actual.getCatalogDiff(), catalogDiff); assertEquals(actual.getCatalog(), expectedActorCatalog); - assertEquals(actual.getConnectionStatus(), ConnectionStatus.ACTIVE); + assertEquals(actual.getConnectionStatus(), ConnectionStatus.INACTIVE); } @Test