@Test
public void inPortHasSignal() {

    try (ModuleInterpretation moduleInterpretation = testCaseBuilder("successfulExecution").build()) {
        Props props = moduleInterpretation.toSimpleModuleInterpreterProps(MODULE_ID, bitSetOf(0, 1), bitSetOf(0));
        TestActorRef<SimpleModuleInterpreterActor> actorRef = TestActorRef.create(
            moduleInterpretation.getActorSystem(), props, moduleInterpretation.getSupervisor());
        // Now send InPortHasSignal messages
        TestProbe executorProbe = moduleInterpretation.getExecutorProbe();
        Assert.assertFalse(executorProbe.msgAvailable());
        actorRef.receive(new InPortHasSignal(0));
        Assert.assertFalse(executorProbe.msgAvailable());
        actorRef.receive(new InPortHasSignal(1));
        // Verify that executor receives an ExecuteTrace message
        ExecuteTrace executeTraceMessage = executorProbe.expectMsgClass(ExecuteTrace.class);
        RuntimeStateProvider runtimeStateProvider = executeTraceMessage.getRuntimeStateProvider();
        InstanceProvider instanceProvider = mock(InstanceProvider.class);
        RuntimeContext restoredRuntimeContext = await(runtimeStateProvider.provideRuntimeContext(instanceProvider));
        Assert.assertSame(restoredRuntimeContext.getRepository(), repository);
        // Send the SimpleModuleExecutorResult that the executor would send. Verify that the parent actor receives a
        // SubmoduleOutPortHasSignal message
        SimpleModuleExecutorResult executionResult = new SimpleModuleExecutorResult.Builder(
                Name.qualifiedName(SimpleModuleExecutorResult.class.getName()))
            .build();
        actorRef.receive(executionResult);
        TestProbe parentProbe = moduleInterpretation.getParentProbe();
        parentProbe.expectMsg(new SubmoduleOutPortHasSignal(MODULE_ID, 0));
        // Verify that the actor terminates properly. The Akka manual says: "the watching actor will receive a
        // Terminated message even if the watched actor has already been terminated at the time of registration."
        parentProbe.watch(actorRef);
        parentProbe.expectMsgClass(Terminated.class);
        Assert.assertFalse(parentProbe.msgAvailable());
    }
}