private Optional<String> lookup(final ReferenceData referenceData,
                                    final List<PipelineReference> pipelineReferences,
                                    final long time,
                                    final String mapName,
                                    final String key) {
        final LookupIdentifier lookupIdentifier = LookupIdentifier.of(mapName, key, time);
        final ReferenceDataResult result = new ReferenceDataResult(lookupIdentifier);

        referenceData.ensureReferenceDataAvailability(
                pipelineReferences,
                lookupIdentifier,
                result);

        if (result.getRefDataValueProxy().isPresent()) {
            return result.getRefDataValueProxy()
                    .flatMap(RefDataValueProxy::supplyValue)
                    .flatMap(val -> Optional.of(((StringValue) val).getValue()));
        } else {
            return Optional.empty();
        }
    }
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