AcknowledgementForwarderActor extends AbstractActor { public static String determineActorName(final DittoHeaders dittoHeaders) { checkNotNull(dittoHeaders, "dittoHeaders"); final String correlationId = dittoHeaders.getCorrelationId() .orElseThrow(() -> AcknowledgementCorrelationIdMissingException.newBuilder() .dittoHeaders(dittoHeaders) .build()); return ACTOR_NAME_PREFIX + URLEncoder.encode(correlationId, Charset.defaultCharset()); } @SuppressWarnings("unused") private  AcknowledgementForwarderActor(final ActorRef acknowledgementRequester, final DittoHeaders dittoHeaders,
            final Duration defaultTimeout); @Override Receive createReceive(); static String determineActorName(final DittoHeaders dittoHeaders); static Optional<ActorRef> startAcknowledgementForwarder(final akka.actor.ActorContext context,
            final EntityIdWithType entityId,
            final Signal<?> signal,
            final AcknowledgementConfig acknowledgementConfig); static Signal<?> startAcknowledgementForwarderConflictFree(final akka.actor.ActorContext context,
            final EntityIdWithType entityId,
            final Signal<?> signal,
            final AcknowledgementConfig acknowledgementConfig);  }
@Test public void tryToDetermineActorNameFromNullHeaders() { assertThatNullPointerException() .isThrownBy(() -> AcknowledgementForwarderActor.determineActorName(null)) .withMessage("The dittoHeaders must not be null!") .withNoCause(); }
@Test public void determineActorNameReturnsExpected() { final String correlationId = "my-correlation-id"; final DittoHeaders dittoHeaders = DittoHeaders.newBuilder().correlationId(correlationId).build(); final String expected = AcknowledgementForwarderActor.ACTOR_NAME_PREFIX + correlationId; final String actual = AcknowledgementForwarderActor.determineActorName(dittoHeaders); assertThat(actual).isEqualTo(expected); }
@Test public void tryToDetermineActorNameWithMissingCorrelationId() { final DittoHeaders dittoHeaders = DittoHeaders.newBuilder() .acknowledgementRequest(AcknowledgementRequest.of(AcknowledgementLabel.of("my-requested-ack"))) .build(); assertThatExceptionOfType(AcknowledgementCorrelationIdMissingException.class) .isThrownBy(() -> AcknowledgementForwarderActor.determineActorName(dittoHeaders)); }