/*
 * Copyright 1998-2014 University Corporation for Atmospheric Research/Unidata
 *
 *   Portions of this software were developed by the Unidata Program at the
 *   University Corporation for Atmospheric Research.
 *
 *   Access and use of this software shall impose the following obligations
 *   and understandings on the user. The user is granted the right, without
 *   any fee or cost, to use, copy, modify, alter, enhance and distribute
 *   this software, and any derivative works thereof, and its supporting
 *   documentation for any purpose whatsoever, provided that this entire
 *   notice appears in all copies of the software, derivative works and
 *   supporting documentation.  Further, UCAR requests that the user credit
 *   UCAR/Unidata in any publications that result from the use of this
 *   software or in any product that includes this software. The names UCAR
 *   and/or Unidata, however, may not be used in any advertising or publicity
 *   to endorse or promote any products or commercial entity unless specific
 *   written permission is obtained from UCAR/Unidata. The user also
 *   understands that UCAR/Unidata is not obligated to provide the user with
 *   any support, consulting, training or assistance of any kind with regard
 *   to the use, operation and performance of this software nor to provide
 *   the user with any updates, revisions, new versions or "bug fixes."
 *
 *   THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
 *   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 *   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 *   DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
 *   INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
 *   FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 *   NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 *   WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
 */

package ucar.nc2.grib;

import org.junit.Test;
import thredds.catalog.parser.jdom.FeatureCollectionReader;
import thredds.featurecollection.FeatureCollectionConfig;
import thredds.inventory.CollectionUpdateType;
import ucar.nc2.grib.collection.GribCdmIndex;
import ucar.unidata.test.util.TestDir;

import java.io.IOException;

/**
 * Describe
 *
 * @author caron
 * @since 11/14/2014
 */
public class TestGribIndexCreation {

  @Test
  public void testGdsHashChange() throws IOException {
    String dataDir2 = TestDir.cdmUnitTestDir + "gribCollections/gdsHashChange/";
    FeatureCollectionConfig config = FeatureCollectionReader.readFeatureCollection(TestDir.cdmUnitTestDir + "gribCollections/gdsHashChange/config.xml#NDFD-CONUS_5km_conduit");
    org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger("test");
    boolean changed = GribCdmIndex.updateGribCollection(config, CollectionUpdateType.always, logger);
    System.out.printf("changed = %s%n", changed);

  }
}

@@ -2198,16 +2198,93 @@
 teType;%0A
+import ucar.nc2.Group;%0Aimport ucar.nc2.NetcdfFile;%0Aimport ucar.nc2.Variable;%0A
 import u
@@ -2393,24 +2393,246 @@
 on;%0A
-%0A/**%0A * Describe
+import java.util.List;%0A%0A/**%0A * Tests whether a feature collection config that includes gdshash actually%0A * correctly remaps variables onto a common grid. This is addressing a problem%0A * with the NDFD that silently cropped in and back out.
 %0A *%0A
@@ -2646,13 +2646,12 @@
 hor 
-caron
+rmay
 %0A * 
@@ -2661,17 +2661,17 @@
 nce 11/1
-4
+8
 /2014%0A *
@@ -2791,17 +2791,16 @@
  dataDir
-2
  = TestD
@@ -2913,16 +2913,29 @@
 onReader
+%0A            
 .readFea
@@ -2953,63 +2953,39 @@
 ion(
-TestDir.cdmUnitTestDir + %22gribCollections/gdsHashChange
+dataDir +%0A                    %22
 /con
@@ -3098,26 +3098,8 @@
 %0A   
- boolean changed =
  Gri
@@ -3165,16 +3165,28 @@
 .always,
+%0A           
  logger)
@@ -3191,58 +3191,393 @@
 r);%0A
+%0A  
     
-System.out.printf(%22changed = %25s%25n%22, changed);%0A
+// Open the index file%0A      NetcdfFile f = NetcdfFile.open(dataDir +%0A              %22NDFD_CONUS_5km_conduit_20141114_1300.grib2.ncx2%22);%0A%0A      // Check that we have no groups other than the root%0A      List%3CGroup%3E groups = f.getRootGroup().getGroups();%0A      assert groups.size() == 0;%0A%0A      List%3CVariable%3E vars = f.getRootGroup().getVariables();%0A      assert vars.size() == 35;
 %0A  %7D

Add unit test for gdsHash.