content: /*
   * Copyright (C) 2012-2023 52°North Spatial Information Research GmbH
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 as published
   * by the Free Software Foundation.
   *
   * If the program is linked with libraries which are licensed under one of
   * the following licenses, the combination of the program with the linked
   * library is not considered a "derivative work" of the program:
   *
   *     - Apache License, version 2.0
   *     - Apache Software License, version 1.0
   *     - GNU Lesser General Public License, version 3
   *     - Mozilla Public License, versions 1.0, 1.1 and 2.0
   *     - Common Development and Distribution License (CDDL), version 1.0
   *
   * Therefore the distribution of the program linked with libraries licensed
   * under the aforementioned licenses, is permitted by the copyright holders
   * if the distribution is compliant with both the GNU General Public
   * License version 2 and the aforementioned licenses.
   *
   * 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.
   */
  package org.n52.sos.ds.hibernate;
  
  import org.junit.Assert;
  import org.junit.Before;
  import org.junit.Test;
  import org.n52.iceland.coding.SupportedTypeRepository;
  import org.n52.sensorweb.server.db.old.dao.DefaultDbQueryFactory;
  import org.n52.series.db.da.sos.SOSHibernateSessionHolder;
  import org.n52.shetland.ogc.ows.exception.OwsExceptionReport;
  import org.n52.sos.cache.InMemoryCacheImpl;
  import org.n52.sos.cache.SosWritableContentCache;
  import org.n52.sos.ds.SosCacheFeederHandler;
  import org.n52.sos.util.GeometryHandler;
  
  /**
   * @author <a href="mailto:e.h.juerrens@52north.org">Eike Hinderk
   *         J&uuml;rrens</a>
   *
   * @since 4.0.0
   */
  public class SosCacheFeederDAOTest extends HibernateTestCase {
      /* FIXTURES */
      private SosCacheFeederHandler instance;
  
      @Before
      public void initCacheFeeder() {
          instance = new SosCacheFeederHandler();
          SOSHibernateSessionHolder holder = new SOSHibernateSessionHolder();
          holder.setConnectionProvider(this);
          instance.setConnectionProvider(holder);
          instance.setDbQueryFactory(new DefaultDbQueryFactory("4326"));
  
          GeometryHandler geometryHandler = new GeometryHandler();
          geometryHandler.setAuthority("EPSG");
          geometryHandler.setStorageEpsg(4326);
          geometryHandler.setSpatialDatasource(true);
          geometryHandler.init();
          instance.setGeometryHandler(geometryHandler);
      }
  
      @Test
      public void updateCacheFillsCapabilitiesCache()
              throws OwsExceptionReport {
          SosWritableContentCache cache =
                  (InMemoryCacheImpl) new InMemoryCacheImpl().setSupportedTypeRepository(new SupportedTypeRepository());
          instance.updateCache(cache);
          testCacheResult(cache);
      }
  
      @Test(expected = NullPointerException.class)
      public void updateNullThrowsNullPointerException() throws OwsExceptionReport {
          instance.updateCache(null);
      }
  
      /* HELPER */
      private void testCacheResult(SosWritableContentCache cache) {
          Assert.assertNotNull("cache is null", cache);
          Assert.assertNotNull("envelope of features is null", cache.getGlobalEnvelope());
          Assert.assertNotNull("feature types is null", cache.getFeatureOfInterestTypes());
          Assert.assertNotNull("offerings is null", cache.getOfferings());
          // Assert.assertNotNull("max phenomenon time is null",
          // cache.getMaxPhenomenonTime());
          // Assert.assertNotNull("min phenomenon time is null",
          // cache.getMinPhenomenonTime());
          // Assert.assertNotNull("max result time is null", cache.getMaxResultTime());
          // Assert.assertNotNull("min result time is null", cache.getMinResultTime());
          Assert.assertNotNull("observation types is null", cache.getObservationTypes());
          Assert.assertNotNull("result templates is null", cache.getResultTemplates());
      }
  
  }
  