@Test
    void testMissingMaps() {
        pipelineScopeRunnable.scopeRunnable(() -> {
            final DocRef feed1Ref = feedStore.createDocument("TEST_FEED_1");
            final DocRef pipeline1Ref = pipelineStore.createDocument("TEST_PIPELINE_1");

            final List<PipelineReference> pipelineReferences = new ArrayList<>();
            pipelineReferences.add(new PipelineReference(pipeline1Ref, feed1Ref, StreamTypeNames.REFERENCE));
            final String feedName = feed1Ref.getName();
            // Set up the effective streams to be used for each
            final EffectiveMeta stream1 = buildEffectiveMeta(
                    createMeta(feed1Ref.getName()).getId(),
                    "2008-01-01T09:47:00.000Z");
            final EffectiveMeta stream2 = buildEffectiveMeta(
                    createMeta(feed1Ref.getName()).getId(),
                    "2009-01-01T09:47:00.000Z");
            final EffectiveMeta stream3 = buildEffectiveMeta(
                    createMeta(feed1Ref.getName()).getId(),
                    "2010-01-01T09:47:00.000Z");

            final EffectiveMetaSet streamSet1 = EffectiveMetaSet.singleton(stream1);
            final EffectiveMetaSet streamSet2and3 = EffectiveMetaSet.of(stream2, stream3);

            final EffectiveMetaSet streamSetAll = EffectiveMetaSet.of(stream1, stream2, stream3);

            try (CacheManager cacheManager = new CacheManagerImpl()) {
                final EffectiveStreamCache effectiveStreamCache = new EffectiveStreamCache(
                        cacheManager, null, null, null, ReferenceDataConfig::new) {

                    @Override
                    protected EffectiveMetaSet create(final EffectiveStreamKey key) {
                        return streamSetAll.stream()
                                .collect(EffectiveMetaSet.collector(DUMMY_FEED, DUMMY_TYPE));
                    }
                };

                final ReferenceData referenceData = new ReferenceData(
                        new EffectiveStreamService(effectiveStreamCache),
                        new FeedHolder(),
                        null,
                        null,
                        mockDocumentPermissionCache,
                        mockReferenceDataLoader,
                        refDataStoreHolderProvider.get(),
                        new RefDataLoaderHolder(),
                        pipelineStore,
                        new MockSecurityContext(),
                        taskContextFactory,
                        null,
                        null);

                Map<RefStreamDefinition, Runnable> mockLoaderActionsMap = new HashMap<>();

                // Add multiple reference data items to prove that looping over maps works.
                addUserDataToMockReferenceDataLoader(
                        pipeline1Ref,
                        streamSet1,
                        List.of(SID_TO_PF_1),
                        mockLoaderActionsMap);
                addUserDataToMockReferenceDataLoader(
                        pipeline1Ref,
                        streamSet2and3,
                        List.of(SID_TO_PF_1, SID_TO_PF_2),
                        mockLoaderActionsMap);

                // set up the mock loader to load the appropriate data when triggered by a lookup call
                Mockito.doAnswer(
                                invocation -> {
                                    RefStreamDefinition refStreamDefinition = invocation.getArgument(0);

                                    Runnable action = mockLoaderActionsMap.get(refStreamDefinition);
                                    action.run();
                                    return null;
                                }).when(mockReferenceDataLoader)
                        .load(Mockito.any(RefStreamDefinition.class));

                // perform lookups (which will trigger a load if required) and assert the result
                final List<Tuple3<String, String, Boolean>> cases = List.of(
                        Tuple.of("2008-01-01T09:47:00.000Z", SID_TO_PF_2, false), // map not in this stream
                        Tuple.of("2009-01-01T09:47:00.111Z", SID_TO_PF_2, true), // Map found in this stream
                        Tuple.of("2010-01-01T09:47:00.111Z", SID_TO_PF_2, true),

                        Tuple.of("2008-01-01T09:47:00.000Z", SID_TO_PF_1, true),
                        Tuple.of("2009-01-01T09:47:00.111Z", SID_TO_PF_1, true),
                        Tuple.of("2010-01-01T09:47:00.111Z", SID_TO_PF_1, true));

                for (final Tuple3<String, String, Boolean> testCase : cases) {
                    final Optional<String> optFoundValue = lookup(
                            referenceData,
                            pipelineReferences,
                            testCase._1,
                            testCase._2, // Map is NOT in the stream
                            USER_1);
                    Assertions.assertThat(optFoundValue.isPresent())
                            .isEqualTo(testCase._3);
                }
            } catch (final RuntimeException e) {
                throw new RuntimeException(e.getMessage(), e);
            }
        });
    }
Make sure that it copes with a map not being in an early stream but is in a later one.
stroom-app/src/test/java/stroom/pipeline/refdata/TestReferenceData.java