@Test
public void checkForActivityOfNonexistentPolicy() {

    new TestKit(actorSystem) {
        {
            // GIVEN: a PolicyPersistenceActor is created in a parent that forwards all messages to us
            final PolicyId policyId = PolicyId.of("test.ns", "nonexistent.policy");
            final Props persistentActorProps =
                    PolicyPersistenceActor.props(policyId, new PolicyMongoSnapshotAdapter(), pubSubMediator);
            final TestProbe errorsProbe = TestProbe.apply(actorSystem);
            final Props parentProps = Props.create(Actor.class, () -> new AbstractActor() {
                @Override
                public void preStart() {
                    getContext().actorOf(persistentActorProps);
                }
                @Override
                public SupervisorStrategy supervisorStrategy() {
                    return new OneForOneStrategy(true,
                            DeciderBuilder.matchAny(throwable -> {
                                errorsProbe.ref().tell(throwable, getSelf());
                                return SupervisorStrategy.restart();
                            }).build());
                }
                @Override
                public Receive createReceive() {
                    return ReceiveBuilder.create()
                            .matchAny(message -> {
                                if (getTestActor().equals(getSender())) {
                                    getContext().actorSelection(getSelf().path().child("*"))
                                            .forward(message, getContext());
                                } else {
                                    getTestActor().forward(message, getContext());
                                }
                            })
                            .build();
                }
            });
            // WHEN: CheckForActivity is sent to a persistence actor of nonexistent policy after startup
            final ActorRef underTest = actorSystem.actorOf(parentProps);
            final Object checkForActivity = AbstractShardedPersistenceActor.checkForActivity(1L);
            underTest.tell(checkForActivity, getRef());
            underTest.tell(checkForActivity, getRef());
            underTest.tell(checkForActivity, getRef());
            // THEN: persistence actor requests shutdown
            expectMsg(PolicySupervisorActor.Control.PASSIVATE);
            // THEN: persistence actor should not throw anything.
            errorsProbe.expectNoMessage(scala.concurrent.duration.Duration.create(3, TimeUnit.SECONDS));
        }
    };
}