@Test(dependsOnMethods = {"testMetadataLevel"})
 public void testLogicalChannelRefs() {
   Class<? extends IObject> klass = LogicalChannel.class;
   List<IObjectContainer> containers = store.getIObjectContainers(klass);
   referenceCache = store.getReferenceCache();
   for (IObjectContainer container : containers) {
     LSID lsid = new LSID(container.LSID);
     if (!referenceCache.containsKey(lsid)) {
       continue;
     }
     List<LSID> references = referenceCache.get(lsid);
     assertTrue(references.size() > 0);
     for (LSID referenceLSID : references) {
       String asString = referenceLSID.toString();
       if (asString.endsWith(OMEROMetadataStoreClient.OMERO_EMISSION_FILTER_SUFFIX)
           || asString.endsWith(OMEROMetadataStoreClient.OMERO_EXCITATION_FILTER_SUFFIX)) {
         int index = asString.lastIndexOf(':');
         referenceLSID = new LSID(asString.substring(0, index));
       }
       assertNotNull(referenceLSID);
       List<Class<? extends IObject>> klasses = new ArrayList<Class<? extends IObject>>();
       klasses.add(Filter.class);
       klasses.add(FilterSet.class);
       String e = String.format("LSID %s not found in container cache", referenceLSID);
       assertTrue(e, authoritativeLSIDExists(klasses, referenceLSID));
     }
   }
 }
 /**
  * Dumps <code>TRACE</code> data for a given metadata store.
  *
  * @param store The store to dump <code>TRACE</code> data for.
  */
 private void traceMetadataStoreData(OMEROMetadataStoreClient store) {
   containerCache = store.getContainerCache();
   referenceCache = store.getReferenceCache();
   log.trace("Starting container cache...");
   for (LSID key : containerCache.keySet()) {
     String s =
         String.format(
             "%s == %s,%s",
             key, containerCache.get(key).sourceObject, containerCache.get(key).LSID);
     log.trace(s);
   }
   log.trace("Starting reference cache...");
   for (LSID key : referenceCache.keySet()) {
     for (LSID value : referenceCache.get(key)) {
       String s = String.format("%s == %s", key, value);
       log.trace(s);
     }
   }
   log.trace("containerCache contains " + containerCache.size() + " entries.");
   log.trace("referenceCache contains " + store.countCachedReferences(null, null) + " entries.");
   List<IObjectContainer> imageContainers = store.getIObjectContainers(Image.class);
   for (IObjectContainer imageContainer : imageContainers) {
     Image image = (Image) imageContainer.sourceObject;
     log.trace(
         String.format(
             "Image indexes:%s name:%s", imageContainer.indexes, image.getName().getValue()));
   }
 }
 @Test(dependsOnMethods = {"testMetadataLevel"})
 public void testOTFIsReferenced() {
   Class<? extends IObject> klass = OTF.class;
   List<IObjectContainer> containers = store.getIObjectContainers(klass);
   referenceCache = store.getReferenceCache();
   for (IObjectContainer container : containers) {
     LSID lsid = new LSID(container.LSID);
     for (LSID target : referenceCache.keySet()) {
       for (LSID reference : referenceCache.get(target)) {
         if (reference.equals(lsid)) {
           return;
         }
       }
     }
     fail(String.format("%s %s not referenced by any object.", klass, lsid));
   }
 }
 @Test(dependsOnMethods = {"testMetadataLevel"})
 public void testLightSourceSettingsLightSourceRef() {
   Class<? extends IObject> klass = LightSettings.class;
   List<IObjectContainer> containers = store.getIObjectContainers(klass);
   referenceCache = store.getReferenceCache();
   for (IObjectContainer container : containers) {
     LSID lsid = new LSID(container.LSID);
     String e = String.format("%s %s not found in reference cache", klass, container.LSID);
     assertTrue(e, referenceCache.containsKey(lsid));
     List<LSID> references = referenceCache.get(lsid);
     assertTrue(references.size() > 0);
     for (LSID referenceLSID : references) {
       assertNotNull(referenceLSID);
       klass = LightSource.class;
       e = String.format("%s with LSID %s not found in container cache", klass, referenceLSID);
       assertTrue(e, authoritativeLSIDExists(klass, referenceLSID));
     }
   }
 }
 @Test(dependsOnMethods = {"testMetadataLevel"})
 public void testFilterSetRefs() {
   Class<? extends IObject> klass = FilterSet.class;
   List<IObjectContainer> containers = store.getIObjectContainers(klass);
   referenceCache = store.getReferenceCache();
   for (IObjectContainer container : containers) {
     LSID lsid = new LSID(container.LSID);
     if (!referenceCache.containsKey(lsid)) {
       continue;
     }
     List<LSID> references = referenceCache.get(lsid);
     assertTrue(references.size() > 0);
     for (LSID referenceLSID : references) {
       assertNotNull(referenceLSID);
       List<Class<? extends IObject>> klasses = new ArrayList<Class<? extends IObject>>();
       klasses.add(Filter.class);
       klasses.add(Dichroic.class);
       String e = String.format("LSID %s not found in container cache", referenceLSID);
       assertTrue(e, authoritativeLSIDExists(klasses, referenceLSID));
     }
   }
 }