@Test
public void exceptionDuringClientActorPropsCreation() {

    new TestKit(actorSystem) {{
        final Props connectionActorProps =
                ConnectionPersistenceActor.props(TestConstants.createRandomConnectionId(),
                        TestConstants.dummyDittoProtocolSub(pubSubMediator), proxyActor,
                        (connection, proxyActor, connectionActor) -> {
                            throw ConnectionConfigurationInvalidException.newBuilder("validation failed...")
                                    .build();
                        }, null);
        // create another actor because this it is stopped and we want to test if the child is terminated
        final TestKit parent = new TestKit(actorSystem);
        final ActorRef connectionActorRef = watch(parent.childActorOf(connectionActorProps));
        // create connection
        connectionActorRef.tell(createConnection, parent.getRef());
        // expect ConnectionConfigurationInvalidException sent to parent
        final Exception exception = parent.expectMsgClass(ConnectionConfigurationInvalidException.class);
        assertThat(exception).hasMessageContaining("validation failed...");
        // connection actor will stop after activity check.
    }};
}