@Test
public void testConnectionHandling() {

    new TestKit(actorSystem) {{
        final TestProbe aggregator = new TestProbe(actorSystem);
        final Props props =
                AmqpClientActor.propsForTests(connection, getRef(), getRef(),
                        (connection1, exceptionListener) -> mockConnection);
        final ActorRef amqpClientActor = actorSystem.actorOf(props);
        watch(amqpClientActor);
        amqpClientActor.tell(OpenConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef());
        expectMsg(CONNECTED_SUCCESS);
        amqpClientActor.tell(RetrieveConnectionStatus.of(CONNECTION_ID, DittoHeaders.empty()), aggregator.ref());
        aggregator.expectMsgClass(ResourceStatus.class);
        amqpClientActor.tell(CloseConnection.of(CONNECTION_ID, DittoHeaders.empty()), getRef());
        expectMsg(DISCONNECTED_SUCCESS);
        amqpClientActor.tell(RetrieveConnectionStatus.of(CONNECTION_ID, DittoHeaders.empty()), aggregator.ref());
        aggregator.expectMsgClass(ResourceStatus.class);
    }};
}