@Test
public void testSignalEnrichment() {

    // GIVEN: test probe actor started with configured values
    final TestProbe proxyActorProbe = TestProbe.apply("mockProxyActorProbe", actorSystem);
    setUpProxyActor(proxyActorProbe.ref());
    new TestKit(actorSystem) {{
        // GIVEN: MessageMappingProcessor started with a test probe as the configured enrichment provider
        final ActorRef underTest = createMessageMappingProcessorActor(this);
        // WHEN: a signal is received with 2 targets, one with enrichment and one without
        final JsonFieldSelector extraFields = JsonFieldSelector.newInstance("attributes/x", "attributes/y");
        final AuthorizationSubject targetAuthSubject = AuthorizationSubject.newInstance("target:auth-subject");
        final AuthorizationSubject targetAuthSubjectWithoutIssuer =
                AuthorizationSubject.newInstance("auth-subject");
        final Target targetWithEnrichment = ConnectivityModelFactory.newTargetBuilder()
                .address("target/address")
                .authorizationContext(AuthorizationContext.newInstance(DittoAuthorizationContextType.UNSPECIFIED,
                        targetAuthSubject))
                .topics(ConnectivityModelFactory.newFilteredTopicBuilder(Topic.TWIN_EVENTS)
                        .withExtraFields(extraFields)
                        .build())
                .build();
        final Target targetWithoutEnrichment = ConnectivityModelFactory.newTargetBuilder(targetWithEnrichment)
                .topics(Topic.TWIN_EVENTS)
                .build();
        final Signal<?> signal = TestConstants.thingModified(Collections.emptyList());
        final OutboundSignal outboundSignal = OutboundSignalFactory.newOutboundSignal(signal,
                Arrays.asList(targetWithEnrichment, targetWithoutEnrichment));
        underTest.tell(outboundSignal, getRef());
        // THEN: Receive a RetrieveThing command from the facade.
        final RetrieveThing retrieveThing = proxyActorProbe.expectMsgClass(RetrieveThing.class);
        assertThat(retrieveThing.getSelectedFields()).contains(extraFields);
        assertThat(retrieveThing.getDittoHeaders().getAuthorizationContext()).containsExactly(targetAuthSubject,
                targetAuthSubjectWithoutIssuer);
        final JsonObject extra = JsonObject.newBuilder().set("/attributes/x", 5).build();
        proxyActorProbe.reply(
                RetrieveThingResponse.of(retrieveThing.getEntityId(), extra, retrieveThing.getDittoHeaders()));
        // THEN: a mapped signal without enrichment arrives first
        final PublishMappedMessage publishMappedMessage = expectMsgClass(PublishMappedMessage.class);
        int i = 0;
        expectPublishedMappedMessage(publishMappedMessage, i++, signal, targetWithoutEnrichment);
        // THEN: Receive an outbound signal with extra fields.
        expectPublishedMappedMessage(publishMappedMessage, i, signal, targetWithEnrichment,
                mapped -> assertThat(mapped.getAdaptable().getPayload().getExtra()).contains(extra));
    }};
}