@@ -977,6 +977,40 @@ void testDiscoverSchemaForSourceMultipleConnectionsFeatureFlagOn() throws IOExce
977
977
assertEquals (ConnectionStatus .INACTIVE , connectionUpdateValues .get (2 ).getStatus ());
978
978
}
979
979
980
+ @ Test
981
+ void testDiscoverSchemaFromSourceIdWithConnectionUpdateNonSuccessResponse () throws IOException , JsonValidationException , ConfigNotFoundException {
982
+ final SourceConnection source = SourceHelpers .generateSource (UUID .randomUUID ());
983
+ final SourceDiscoverSchemaRequestBody request = new SourceDiscoverSchemaRequestBody ().sourceId (source .getSourceId ())
984
+ .connectionId (UUID .randomUUID ());
985
+
986
+ // Mock the source definition.
987
+ when (configRepository .getStandardSourceDefinition (source .getSourceDefinitionId ()))
988
+ .thenReturn (new StandardSourceDefinition ()
989
+ .withDockerRepository (SOURCE_DOCKER_REPO )
990
+ .withDockerImageTag (SOURCE_DOCKER_TAG )
991
+ .withProtocolVersion (SOURCE_PROTOCOL_VERSION )
992
+ .withSourceDefinitionId (source .getSourceDefinitionId ()));
993
+ // Mock the source itself.
994
+ when (configRepository .getSourceConnection (source .getSourceId ())).thenReturn (source );
995
+ // Mock the Discover job results.
996
+ final SynchronousResponse <UUID > discoverResponse = (SynchronousResponse <UUID >) jobResponse ;
997
+ final SynchronousJobMetadata metadata = mock (SynchronousJobMetadata .class );
998
+ when (discoverResponse .isSuccess ()).thenReturn (false );
999
+ when (discoverResponse .getMetadata ()).thenReturn (metadata );
1000
+ when (metadata .isSucceeded ()).thenReturn (false );
1001
+ when (synchronousSchedulerClient .createDiscoverSchemaJob (source , SOURCE_DOCKER_IMAGE , SOURCE_DOCKER_TAG , new Version (SOURCE_PROTOCOL_VERSION ),
1002
+ false ))
1003
+ .thenReturn (discoverResponse );
1004
+
1005
+ final SourceDiscoverSchemaRead actual = schedulerHandler .discoverSchemaForSourceFromSourceId (request );
1006
+
1007
+ assertNull (actual .getCatalog ());
1008
+ assertNotNull (actual .getJobInfo ());
1009
+ assertFalse (actual .getJobInfo ().getSucceeded ());
1010
+ verify (synchronousSchedulerClient ).createDiscoverSchemaJob (source , SOURCE_DOCKER_IMAGE , SOURCE_DOCKER_TAG , new Version (SOURCE_PROTOCOL_VERSION ),
1011
+ false );
1012
+ }
1013
+
980
1014
@ Test
981
1015
void testDiscoverSchemaForSourceFromSourceCreate () throws JsonValidationException , IOException , ConfigNotFoundException {
982
1016
final SourceConnection source = new SourceConnection ()
0 commit comments