test_class.declarator: ACKNOWLEDGEMENT_LABEL = AcknowledgementLabel.of("twin-persisted")
test_class.modifier: private static final
test_class.original_string: private static final AcknowledgementLabel ACKNOWLEDGEMENT_LABEL = AcknowledgementLabel.of("twin-persisted");
test_class.type: AcknowledgementLabel
test_class.var_name: ACKNOWLEDGEMENT_LABEL
test_class.declarator: testName = new TestName()
test_class.modifier: @Rule
      public final
test_class.original_string: @Rule
      public final TestName testName = new TestName();
test_class.type: TestName
test_class.var_name: testName
test_class.declarator: mappedOutboundSignal
test_class.modifier: @Mock private
test_class.original_string: @Mock private OutboundSignal.Mapped mappedOutboundSignal;
test_class.type: OutboundSignal.Mapped
test_class.var_name: mappedOutboundSignal
test_class.declarator: externalMessage
test_class.modifier: @Mock private
test_class.original_string: @Mock private ExternalMessage externalMessage;
test_class.type: ExternalMessage
test_class.var_name: externalMessage
test_class.declarator: genericTarget
test_class.modifier: @Mock private
test_class.original_string: @Mock private GenericTarget genericTarget;
test_class.type: GenericTarget
test_class.var_name: genericTarget
test_class.declarator: publishedMonitor
test_class.modifier: @Mock private
test_class.original_string: @Mock private ConnectionMonitor publishedMonitor;
test_class.type: ConnectionMonitor
test_class.var_name: publishedMonitor
test_class.declarator: acknowledgedMonitor
test_class.modifier: @Mock private
test_class.original_string: @Mock private ConnectionMonitor acknowledgedMonitor;
test_class.type: ConnectionMonitor
test_class.var_name: acknowledgedMonitor
test_class.declarator: droppedMonitor
test_class.modifier: @Mock private
test_class.original_string: @Mock private ConnectionMonitor droppedMonitor;
test_class.type: ConnectionMonitor
test_class.var_name: droppedMonitor
test_class.declarator: autoAckTarget
test_class.modifier: @Mock private
test_class.original_string: @Mock private Target autoAckTarget;
test_class.type: Target
test_class.var_name: autoAckTarget
test_class.declarator: logger
test_class.modifier: @Mock private
test_class.original_string: @Mock private ThreadSafeDittoLoggingAdapter logger;
test_class.type: ThreadSafeDittoLoggingAdapter
test_class.var_name: logger
test_class.declarator: dittoHeaders
test_class.modifier: private
test_class.original_string: private DittoHeaders dittoHeaders;
test_class.type: DittoHeaders
test_class.var_name: dittoHeaders
test_class.declarator: sendingContext
test_class.modifier: private
test_class.original_string: private SendingContext sendingContext;
test_class.type: SendingContext
test_class.var_name: sendingContext
test_class.declarator: exceptionConverter
test_class.modifier: private
test_class.original_string: private ExceptionToAcknowledgementConverter exceptionConverter;
test_class.type: ExceptionToAcknowledgementConverter
test_class.var_name: exceptionConverter
test_class.file: services/connectivity/messaging/src/test/java/org/eclipse/ditto/services/connectivity/messaging/SendingTest.java
test_class.identifier: SendingTest
test_case.body: @Test
      public void monitorAcknowledgementSendFailureKeepOriginalResponse() {
          final var acknowledgement = Mockito.mock(Acknowledgement.class);
          final var acknowledgementPayload = JsonObject.newBuilder().set("foo", "bar").build();
          final var acknowledgementStatusCode = HttpStatusCode.INTERNAL_SERVER_ERROR;
          Mockito.when(acknowledgement.getStatusCode()).thenReturn(acknowledgementStatusCode);
          Mockito.when(acknowledgement.getEntity()).thenReturn(Optional.of(acknowledgementPayload));
          final var expectedException = MessageSendingFailedException.newBuilder()
                  .statusCode(acknowledgementStatusCode)
                  .message("Received negative acknowledgement for label <" + ACKNOWLEDGEMENT_LABEL + ">.")
                  .description("Payload: " + acknowledgementPayload)
                  .build();
          final Sending underTest =
                  new Sending(sendingContext, CompletableFuture.completedStage(acknowledgement), logger);
  
          final Optional<CompletionStage<CommandResponse>> result = underTest.monitorAndAcknowledge(exceptionConverter);
  
          Mockito.verifyNoInteractions(publishedMonitor);
          Mockito.verify(acknowledgedMonitor).failure(externalMessage, expectedException);
          assertThat(result)
                  .hasValueSatisfying(resultFuture -> assertThat(resultFuture).isCompletedWithValue(acknowledgement));
      }
test_case.class_method_signature: SendingTest.monitorAcknowledgementSendFailureKeepOriginalResponse()
test_case.full_signature: @Test public void monitorAcknowledgementSendFailureKeepOriginalResponse()
test_case.identifier: monitorAcknowledgementSendFailureKeepOriginalResponse
test_case.invocations: mock build set newBuilder thenReturn when getStatusCode thenReturn when getEntity of build description message statusCode newBuilder completedStage monitorAndAcknowledge verifyNoInteractions failure verify hasValueSatisfying assertThat isCompletedWithValue assertThat
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void monitorAcknowledgementSendFailureKeepOriginalResponse()
focal_class.declarator: sendingContext
focal_class.modifier: private final
focal_class.original_string: private final SendingContext sendingContext;
focal_class.type: SendingContext
focal_class.var_name: sendingContext
focal_class.declarator: futureResponse
focal_class.modifier: private final
focal_class.original_string: private final CompletionStage<CommandResponse<?>> futureResponse;
focal_class.type: CompletionStage<CommandResponse<?>>
focal_class.var_name: futureResponse
focal_class.declarator: logger
focal_class.modifier: private final
focal_class.original_string: private final ThreadSafeDittoLoggingAdapter logger;
focal_class.type: ThreadSafeDittoLoggingAdapter
focal_class.var_name: logger
focal_class.file: services/connectivity/messaging/src/main/java/org/eclipse/ditto/services/connectivity/messaging/Sending.java
focal_class.identifier: Sending
focal_class.interfaces: implements SendingOrDropped
focal_class.class_method_signature: Sending.Sending(final SendingContext sendingContext, final CompletionStage<CommandResponse<?>> futureResponse,
              final ThreadSafeDittoLoggingAdapter logger)
focal_class.full_signature:   Sending(final SendingContext sendingContext, final CompletionStage<CommandResponse<?>> futureResponse,
              final ThreadSafeDittoLoggingAdapter logger)
focal_class.identifier: Sending
focal_class.parameters: (final SendingContext sendingContext, final CompletionStage<CommandResponse<?>> futureResponse,
              final ThreadSafeDittoLoggingAdapter logger)
focal_class.signature:  Sending(final SendingContext sendingContext, final CompletionStage<CommandResponse<?>> futureResponse,
              final ThreadSafeDittoLoggingAdapter logger)
focal_class.class_method_signature: Sending.monitorAndAcknowledge(
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.full_signature: @SuppressWarnings("rawtypes") @Override public Optional<CompletionStage<CommandResponse>> monitorAndAcknowledge(
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.identifier: monitorAndAcknowledge
focal_class.modifiers: @SuppressWarnings("rawtypes") @Override public
focal_class.parameters: (
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.return: Optional<CompletionStage<CommandResponse>>
focal_class.signature: Optional<CompletionStage<CommandResponse>> monitorAndAcknowledge(
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.class_method_signature: Sending.acknowledge(@Nullable final CommandResponse<?> response,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.full_signature: @Nullable private CommandResponse<?> acknowledge(@Nullable final CommandResponse<?> response,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.identifier: acknowledge
focal_class.modifiers: @Nullable private
focal_class.parameters: (@Nullable final CommandResponse<?> response,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.return: CommandResponse<?>
focal_class.signature: CommandResponse<?> acknowledge(@Nullable final CommandResponse<?> response,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.class_method_signature: Sending.getNullAckException()
focal_class.full_signature: private static MessageSendingFailedException getNullAckException()
focal_class.identifier: getNullAckException
focal_class.modifiers: private static
focal_class.parameters: ()
focal_class.return: MessageSendingFailedException
focal_class.signature: MessageSendingFailedException getNullAckException()
focal_class.class_method_signature: Sending.monitor(@Nullable final CommandResponse<?> response)
focal_class.full_signature: @SuppressWarnings({"rawtypes", "java:S3740"}) @Nullable private CommandResponse monitor(@Nullable final CommandResponse<?> response)
focal_class.identifier: monitor
focal_class.modifiers: @SuppressWarnings({"rawtypes", "java:S3740"}) @Nullable private
focal_class.parameters: (@Nullable final CommandResponse<?> response)
focal_class.return: CommandResponse
focal_class.signature: CommandResponse monitor(@Nullable final CommandResponse<?> response)
focal_class.class_method_signature: Sending.isAcknowledgement(final CommandResponse<?> commandResponse)
focal_class.full_signature: private static boolean isAcknowledgement(final CommandResponse<?> commandResponse)
focal_class.identifier: isAcknowledgement
focal_class.modifiers: private static
focal_class.parameters: (final CommandResponse<?> commandResponse)
focal_class.return: boolean
focal_class.signature: boolean isAcknowledgement(final CommandResponse<?> commandResponse)
focal_class.class_method_signature: Sending.monitorAcknowledgement(final Acknowledgement acknowledgement)
focal_class.full_signature: private void monitorAcknowledgement(final Acknowledgement acknowledgement)
focal_class.identifier: monitorAcknowledgement
focal_class.modifiers: private
focal_class.parameters: (final Acknowledgement acknowledgement)
focal_class.return: void
focal_class.signature: void monitorAcknowledgement(final Acknowledgement acknowledgement)
focal_class.class_method_signature: Sending.isTargetIssuesLiveResponse()
focal_class.full_signature: private boolean isTargetIssuesLiveResponse()
focal_class.identifier: isTargetIssuesLiveResponse
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isTargetIssuesLiveResponse()
focal_class.class_method_signature: Sending.monitorLiveResponse(final CommandResponse<?> liveResponse)
focal_class.full_signature: private void monitorLiveResponse(final CommandResponse<?> liveResponse)
focal_class.identifier: monitorLiveResponse
focal_class.modifiers: private
focal_class.parameters: (final CommandResponse<?> liveResponse)
focal_class.return: void
focal_class.signature: void monitorLiveResponse(final CommandResponse<?> liveResponse)
focal_class.class_method_signature: Sending.handleException(final Exception exception,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.full_signature: @Nullable private Acknowledgement handleException(final Exception exception,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.identifier: handleException
focal_class.modifiers: @Nullable private
focal_class.parameters: (final Exception exception,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.return: Acknowledgement
focal_class.signature: Acknowledgement handleException(final Exception exception,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.class_method_signature: Sending.monitorSendFailure(final Exception exception)
focal_class.full_signature: private void monitorSendFailure(final Exception exception)
focal_class.identifier: monitorSendFailure
focal_class.modifiers: private
focal_class.parameters: (final Exception exception)
focal_class.return: void
focal_class.signature: void monitorSendFailure(final Exception exception)
focal_class.class_method_signature: Sending.convertExceptionToAcknowledgementOrNull(final Exception exception,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.full_signature: @Nullable private Acknowledgement convertExceptionToAcknowledgementOrNull(final Exception exception,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.identifier: convertExceptionToAcknowledgementOrNull
focal_class.modifiers: @Nullable private
focal_class.parameters: (final Exception exception,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.return: Acknowledgement
focal_class.signature: Acknowledgement convertExceptionToAcknowledgementOrNull(final Exception exception,
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_class.class_method_signature: Sending.getRootCause(final Throwable throwable)
focal_class.full_signature: @SuppressWarnings("ChainOfInstanceofChecks") private static Exception getRootCause(final Throwable throwable)
focal_class.identifier: getRootCause
focal_class.modifiers: @SuppressWarnings("ChainOfInstanceofChecks") private static
focal_class.parameters: (final Throwable throwable)
focal_class.return: Exception
focal_class.signature: Exception getRootCause(final Throwable throwable)
focal_method.body: @SuppressWarnings("rawtypes")
      @Override
      public Optional<CompletionStage<CommandResponse>> monitorAndAcknowledge(
              final ExceptionToAcknowledgementConverter exceptionConverter) {
  
          return Optional.of(futureResponse
                  .thenApply(response -> acknowledge(response, exceptionConverter))
                  .thenApply(this::monitor)
                  .exceptionally(error -> {
                      final Acknowledgement result = handleException(getRootCause(error), exceptionConverter);
                      monitor(result);
                      return result;
                  }));
      }
focal_method.class_method_signature: Sending.monitorAndAcknowledge(
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_method.full_signature: @SuppressWarnings("rawtypes") @Override public Optional<CompletionStage<CommandResponse>> monitorAndAcknowledge(
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_method.identifier: monitorAndAcknowledge
focal_method.invocations: of exceptionally thenApply thenApply acknowledge handleException getRootCause monitor
focal_method.modifiers: @SuppressWarnings("rawtypes") @Override public
focal_method.parameters: (
              final ExceptionToAcknowledgementConverter exceptionConverter)
focal_method.return: Optional<CompletionStage<CommandResponse>>
focal_method.signature: Optional<CompletionStage<CommandResponse>> monitorAndAcknowledge(
              final ExceptionToAcknowledgementConverter exceptionConverter)