@Test
    void testRange() {
        pipelineScopeRunnable.scopeRunnable(() -> {
            final DocRef feed1Ref = feedStore.createDocument("TEST_FEED_V1");
            final FeedDoc feedDoc = feedStore.readDocument(feed1Ref);
            feedDoc.setReference(true);
            feedStore.writeDocument(feedDoc);

            final DocRef pipelineRef = pipelineStore.createDocument("12345");
            final PipelineReference pipelineReference = new PipelineReference(pipelineRef,
                    feed1Ref,
                    StreamTypeNames.REFERENCE);
            final List<PipelineReference> pipelineReferences = Collections.singletonList(pipelineReference);

            final EffectiveMetaSet streamSet = EffectiveMetaSet.builder(DUMMY_FEED, DUMMY_TYPE)
                    .add(createMeta(feed1Ref.getName()).getId(), 0L)
                    .build();

            try (CacheManager cacheManager = new CacheManagerImpl()) {
                final EffectiveStreamCache effectiveStreamCache = new EffectiveStreamCache(cacheManager,
                        null,
                        null,
                        null,
                        ReferenceDataConfig::new) {
                    @Override
                    protected EffectiveMetaSet create(final EffectiveStreamKey key) {
                        return streamSet;
                    }
                };

                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.
                addRangeValueDataToMockReferenceDataLoader(
                        pipelineRef,
                        streamSet,
                        Arrays.asList(
                                Tuple.of(IP_TO_LOC_MAP_NAME, Range.of(2L, 30L), VALUE_1),
                                Tuple.of(IP_TO_LOC_MAP_NAME, Range.of(40L, 41L), VALUE_2),
                                Tuple.of(IP_TO_LOC_MAP_NAME, Range.of(500L, 2000L), VALUE_3),
                                Tuple.of(IP_TO_LOC_MAP_NAME, Range.of(3000L, 3001L), VALUE_4)),
                        mockLoaderActionsMap);

                Mockito.doAnswer(invocation -> {
                    RefStreamDefinition refStreamDefinition = invocation.getArgument(0);

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

                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "1"))
                        .isEmpty();
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "2"))
                        .contains(VALUE_1);
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "10"))
                        .contains(VALUE_1);
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "29"))
                        .contains(VALUE_1);
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "30"))
                        .isEmpty();
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "40"))
                        .contains(VALUE_2);
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "500"))
                        .contains(VALUE_3);
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "1000"))
                        .contains(VALUE_3);
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "1999"))
                        .contains(VALUE_3);
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "2000"))
                        .isEmpty();
                assertThat(lookup(referenceData, pipelineReferences, 0, "IP_TO_LOC_MAP_NAME", "3000"))
                        .contains(VALUE_4);
            } catch (final Exception 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