gt:         int sizeC = wrapper.getSizeC();
context: /*
   * ome.formats.utests.MetadataValidatorTest
   *
   *------------------------------------------------------------------------------
   *  Copyright (C) 2009 University of Dundee. All rights reserved.
   *
   *
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation; either version 2 of the License, or
   *  (at your option) any later version.
   *  This program is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
   *
   *  You should have received a copy of the GNU General Public License along
   *  with this program; if not, write to the Free Software Foundation, Inc.,
   *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   *
   *------------------------------------------------------------------------------
   */
  
  package ome.formats.utests;
  
  import static org.testng.AssertJUnit.assertEquals;
  import static org.testng.AssertJUnit.assertFalse;
  import static org.testng.AssertJUnit.assertNotNull;
  import static org.testng.AssertJUnit.assertTrue;
  import static org.testng.AssertJUnit.fail;
  
  import java.io.IOException;
  import java.security.MessageDigest;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Date;
  import java.util.GregorianCalendar;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  import loci.common.DataTools;
  import loci.formats.FormatException;
  import loci.formats.in.DefaultMetadataOptions;
  import loci.formats.in.MetadataLevel;
  
  import ome.formats.Index;
  import ome.formats.OMEROMetadataStoreClient;
  import ome.formats.importer.ImportConfig;
  import ome.formats.importer.OMEROWrapper;
  import ome.formats.model.BlitzInstanceProvider;
  import ome.util.LSID;
  import omero.api.ServiceFactoryPrx;
  import omero.metadatastore.IObjectContainer;
  import omero.model.Channel;
  import omero.model.Detector;
  import omero.model.DetectorSettings;
  import omero.model.Dichroic;
  import omero.model.Filter;
  import omero.model.FilterSet;
  import omero.model.IObject;
  import omero.model.Image;
  import omero.model.Instrument;
  import omero.model.LightSettings;
  import omero.model.LightSource;
  import omero.model.LogicalChannel;
  import omero.model.OTF;
  import omero.model.Objective;
  import omero.model.ObjectiveSettings;
  import omero.model.Pixels;
  import omero.model.PlaneInfo;
  import omero.model.Plate;
  import omero.model.Well;
  import omero.model.WellSample;
  
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.testng.annotations.AfterClass;
  import org.testng.annotations.BeforeClass;
  import org.testng.annotations.Parameters;
  import org.testng.annotations.Test;
  
  /**
   * Generic set of unit tests, that are designed to be initiated on a
   * Bio-Formats "ID" target, which sanity check metadata validity.
   *
   * @author Chris Allan <callan at blackcat dot ca>
   *
   */
  @Test(groups={"manual"})
  public class MetadataValidatorTest
  {
      /** Logger for this class */
      private static final Logger log =
          LoggerFactory.getLogger(MetadataValidatorTest.class);
  
      /** Our testing Metadata store client */
      private OMEROMetadataStoreClient store;
  
      /** Our testing Metadata store client (minimum metadata). */
      private OMEROMetadataStoreClient minimalStore;
  
      /** The OMERO basic wrapper for Bio-Formats readers */
      private OMEROWrapper wrapper;
  
      /** The OMERO basic wrapper (initialized with minimum metadata). */
      private OMEROWrapper minimalWrapper;
  
      /** Our current container cache. */
      private Map<LSID, IObjectContainer> containerCache;
  
      /** Our current reference cache. */
      private Map<LSID, List<LSID>> referenceCache;
  
      /** Our testing service factory. */
      private ServiceFactoryPrx sf;
  
      /** Our import configuration. */
      private ImportConfig config;
  
      @Parameters({ "target" })
      @BeforeClass
      public void setUp(String target) throws Exception
      {
          log.info("METADATA VALIDATOR TARGET: " + target);
          sf = new TestServiceFactory().proxy();
          config = new ImportConfig();
          // Let the user know at what level we're logging
          ch.qos.logback.classic.Logger lociLogger =
                  (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("loci");
          ch.qos.logback.classic.Logger omeLogger =
                  (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("ome.formats");
          log.info(String.format(
                  "Log levels -- Bio-Formats: %s OMERO.importer: %s",
                  lociLogger.getLevel(), omeLogger.getLevel()));
          store = new OMEROMetadataStoreClient();
          store.initialize(sf);
          store.setEnumerationProvider(new TestEnumerationProvider());
          store.setInstanceProvider(
                  new BlitzInstanceProvider(store.getEnumerationProvider()));
          minimalStore = new OMEROMetadataStoreClient();
          minimalStore.initialize(sf);
          minimalStore.setEnumerationProvider(new TestEnumerationProvider());
          minimalStore.setInstanceProvider(
                  new BlitzInstanceProvider(minimalStore.getEnumerationProvider()));
          wrapper = new OMEROWrapper(config);
          wrapper.setMetadataOptions(
                  new DefaultMetadataOptions(MetadataLevel.ALL));
          minimalWrapper = new OMEROWrapper(config);
          minimalWrapper.setMetadataOptions(
                  new DefaultMetadataOptions(MetadataLevel.MINIMUM));
          wrapper.setMetadataStore(store);
          store.setReader(wrapper.getImageReader());
          minimalStore.setReader(minimalWrapper.getImageReader());
      }
  
      @AfterClass
      public void tearDown() throws IOException
      {
          wrapper.close();
          minimalWrapper.close();
          store.logout();
          minimalStore.logout();
      }
  
      @Parameters({ "target" })
      @Test
      public void testMetadataLevelAllSetId(String target) throws Exception
      {
          wrapper.setId(target);
          store.postProcess();
          traceMetadataStoreData(store);
      }
  
      @Parameters({ "target" })
      @Test
      public void testMetadataLevelMinimumSetId(String target) throws Exception
      {
          minimalWrapper.setId(target);
          minimalStore.postProcess();
          traceMetadataStoreData(minimalStore);
      }
  
      @Test(dependsOnMethods=
              {"testMetadataLevelAllSetId", "testMetadataLevelMinimumSetId"})
      public void testMetadataLevel()
          throws FormatException, IOException
      {
          assertEquals(MetadataLevel.MINIMUM,
                  minimalWrapper.getMetadataOptions().getMetadataLevel());
          assertEquals(MetadataLevel.ALL,
                  wrapper.getMetadataOptions().getMetadataLevel());
          assertFalse(0 == (wrapper.getSeriesMetadata().size()
                            + wrapper.getGlobalMetadata().size()));
      }
  
      @Test(dependsOnMethods={"testMetadataLevel"})
      public void testMetadataLevelEquivilentDimensions()
      {
          assertEquals(wrapper.getSeriesCount(), minimalWrapper.getSeriesCount());
          for (int i = 0; i < minimalWrapper.getSeriesCount(); i++)
          {
              wrapper.setSeries(i);
              minimalWrapper.setSeries(i);
              assertEquals(wrapper.getSizeX(), minimalWrapper.getSizeX());
              assertEquals(wrapper.getSizeY(), minimalWrapper.getSizeY());
              assertEquals(wrapper.getSizeZ(), minimalWrapper.getSizeZ());
              assertEquals(wrapper.getSizeC(), minimalWrapper.getSizeC());
              assertEquals(wrapper.getSizeT(), minimalWrapper.getSizeT());
              assertEquals(wrapper.getPixelType(),
                           minimalWrapper.getPixelType());
              assertEquals(wrapper.isLittleEndian(),
                           minimalWrapper.isLittleEndian());
          }
      }
  
      @Test(dependsOnMethods={"testMetadataLevel"})
      public void testMetadataLevelEquivilentUsedFiles()
          throws FormatException, IOException
      {
          for (int i = 0; i < minimalWrapper.getSeriesCount(); i++)
          {
              minimalWrapper.setSeries(i);
              wrapper.setSeries(i);
  
              String[] pixelsOnlyFiles = minimalWrapper.getSeriesUsedFiles();
              String[] allFiles = wrapper.getSeriesUsedFiles();
  
              assertEquals(allFiles.length, pixelsOnlyFiles.length);
  
              Arrays.sort(allFiles);
              Arrays.sort(pixelsOnlyFiles);
  
              for (int j = 0; j < pixelsOnlyFiles.length; j++)
              {
                  assertEquals(allFiles[j], pixelsOnlyFiles[j]);
              }
          }
      }
  
      @Test(dependsOnMethods={"testMetadataLevel"})
      public void testMetadataLevelEquivilentPlaneData()
          throws FormatException, IOException
      {
          for (int i = 0; i < minimalWrapper.getSeriesCount(); i++)
          {
              minimalWrapper.setSeries(i);
              wrapper.setSeries(i);
              assertEquals(wrapper.getImageCount(),
                           minimalWrapper.getImageCount());
              for (int j = 0; j < minimalWrapper.getImageCount(); j++)
              {
                  byte[] pixelsOnlyPlane = minimalWrapper.openBytes(j);
                  String pixelsOnlySHA1 = sha1(pixelsOnlyPlane);
                  byte[] allPlane = wrapper.openBytes(j);
                  String allSHA1 = sha1(allPlane);
  
                  if (!pixelsOnlySHA1.equals(allSHA1))
                  {
                      fail(String.format(
                              "MISMATCH: Series:%d Image:%d PixelsOnly%s All:%s",
                              i, j, pixelsOnlySHA1, allSHA1));
                  }
              }
          }
      }
  
      @Test(dependsOnMethods={"testMetadataLevel"})
      public void testEquivilentBlockRetrievalPlaneData()
          throws FormatException, IOException
      {
          String fileName = wrapper.getCurrentFile();
          int sizeX = wrapper.getSizeX();
          int sizeY = wrapper.getSizeY();
          int sizeZ = wrapper.getSizeZ();
  