src/test/java/ucar/geoapi/NetcdfTransformFactoryTest.java
@Test
    public void testParameterNames() throws FactoryException {
        final Map<String,Integer> names = new LinkedHashMap<>();
        for (final Class<? extends Projection> type : projections) {
            final Projection projection;
            try {
                projection = type.getConstructor().newInstance();
            } catch (ReflectiveOperationException e) {
                throw new AssertionError(e);
            }
            final String projectionName = projection.getClassName();
            if (projectionName.equalsIgnoreCase("LatLonProjection")) {          // Not a map projection.
                continue;
            }
            /*
             * Collect the netCDF parameter names. This code ensures that the same netCDF
             * parameter name is not declared twice. A failure in this test would be more
             * a UCAR library issue than a GeoAPI-wrapper one.
             *
             * The values in the map are the length of parameter value arrays, or 1 if
             * the parameter values are scalar.
             */
            names.clear();
            for (final Parameter param : projection.getProjectionParameters()) {
                final String parameterName = param.getName();
                if (names.put(parameterName, param.isString() ? 1 : param.getLength()) != null) {
                    fail("Duplicated \"" + parameterName + "\" parameter in \"" + projectionName + "\" projection.");
                }
            }
            if (names.remove(CF.GRID_MAPPING_NAME) == null) {
                fail("Missing \"" + CF.GRID_MAPPING_NAME + "\" parameter in \"" + projectionName + "\" projection.");
            }
            /*
             * Ensures that all parameter names known to GeoAPI-wrapper
             * are known to the current netCDF projection implementation.
             */
            final ParameterValueGroup group = factory.getDefaultParameters(projectionName);
            validators.validate(group);
            for (final GeneralParameterValue param : group.values()) {
                String parameterName = param.getDescriptor().getName().getCode();
                final int s = parameterName.lastIndexOf('[');
                if (s >= 0) {
                    parameterName = parameterName.substring(0, s);
                }
                final Integer count = names.remove(parameterName);
                if (count != null) {
                    final int n = count - 1;
                    if (n != 0) {
                        assertNull(names.put(parameterName, n));
                    }
                } else if (!isIgnorable(parameterName)) {
                    fail("Unknown \"" + parameterName + "\" parameter in \"" + projectionName + "\" projection.");
                }
            }
            /*
             * Any remaining parameters in the set are parameter that should have been
             * declared in the GeoAPI wrappers but are not.
             */
            assertTrue("Missing parameter in \"" + projectionName + "\" projection: " + names, names.isEmpty());
        }
    }
/**
     * Ensures that the parameter names are the same than the ones created by the UCAR library.
     *
     * @throws FactoryException if an error occurred while using the {@linkplain #factory}.
     */
Ensures that the parameter names are the same than the ones created by the UCAR library.
@throws FactoryException if an error occurred while using the  #factory.
Ensures that the parameter names are the same than the ones created by the UCAR library . @throws FactoryException if an error occurred while using the #factory .
@Test
    public void testParameterNames() throws FactoryException {
        final Map<String,Integer> names = new LinkedHashMap<>();
        for (final Class<? extends Projection> type : projections) {
            final Projection projection;
            try {
                projection = type.getConstructor().newInstance();
            } catch (ReflectiveOperationException e) {
                throw new AssertionError(e);
            }
            final String projectionName = projection.getClassName();
            if (projectionName.equalsIgnoreCase("LatLonProjection")) {          
                continue;
            }
            /*
             * Collect the netCDF parameter names. This code ensures that the same netCDF
             * parameter name is not declared twice. A failure in this test would be more
             * a UCAR library issue than a GeoAPI-wrapper one.
             *
             * The values in the map are the length of parameter value arrays, or 1 if
             * the parameter values are scalar.
             */
            names.clear();
            for (final Parameter param : projection.getProjectionParameters()) {
                final String parameterName = param.getName();
                if (names.put(parameterName, param.isString() ? 1 : param.getLength()) != null) {
                    fail("Duplicated \"" + parameterName + "\" parameter in \"" + projectionName + "\" projection.");
                }
            }
            if (names.remove(CF.GRID_MAPPING_NAME) == null) {
                fail("Missing \"" + CF.GRID_MAPPING_NAME + "\" parameter in \"" + projectionName + "\" projection.");
            }
            /*
             * Ensures that all parameter names known to GeoAPI-wrapper
             * are known to the current netCDF projection implementation.
             */
            final ParameterValueGroup group = factory.getDefaultParameters(projectionName);
            validators.validate(group);
            for (final GeneralParameterValue param : group.values()) {
                String parameterName = param.getDescriptor().getName().getCode();
                final int s = parameterName.lastIndexOf('[');
                if (s >= 0) {
                    parameterName = parameterName.substring(0, s);
                }
                final Integer count = names.remove(parameterName);
                if (count != null) {
                    final int n = count - 1;
                    if (n != 0) {
                        assertNull(names.put(parameterName, n));
                    }
                } else if (!isIgnorable(parameterName)) {
                    fail("Unknown \"" + parameterName + "\" parameter in \"" + projectionName + "\" projection.");
                }
            }
            /*
             * Any remaining parameters in the set are parameter that should have been
             * declared in the GeoAPI wrappers but are not.
             */
            assertTrue("Missing parameter in \"" + projectionName + "\" projection: " + names, names.isEmpty());
        }
    }
@ Test public void testParameterNames ( ) throws FactoryException { final Map < String , Integer > names = new LinkedHashMap < > ( ) ; for ( final Class < ? extends Projection > type : projections ) { final Projection projection ; try { projection = type . getConstructor ( ) . newInstance ( ) ; } catch ( ReflectiveOperationException e ) { throw new AssertionError ( e ) ; } final String projectionName = projection . getClassName ( ) ; if ( projectionName . equalsIgnoreCase ( "LatLonProjection" ) ) { continue ; } /*
             * Collect the netCDF parameter names. This code ensures that the same netCDF
             * parameter name is not declared twice. A failure in this test would be more
             * a UCAR library issue than a GeoAPI-wrapper one.
             *
             * The values in the map are the length of parameter value arrays, or 1 if
             * the parameter values are scalar.
             */ names . clear ( ) ; for ( final Parameter param : projection . getProjectionParameters ( ) ) { final String parameterName = param . getName ( ) ; if ( names . put ( parameterName , param . isString ( ) ? 1 : param . getLength ( ) ) != null ) { fail ( "Duplicated \"" + parameterName + "\" parameter in \"" + projectionName + "\" projection." ) ; } } if ( names . remove ( CF . GRID_MAPPING_NAME ) == null ) { fail ( "Missing \"" + CF . GRID_MAPPING_NAME + "\" parameter in \"" + projectionName + "\" projection." ) ; } /*
             * Ensures that all parameter names known to GeoAPI-wrapper
             * are known to the current netCDF projection implementation.
             */ final ParameterValueGroup group = factory . getDefaultParameters ( projectionName ) ; validators . validate ( group ) ; for ( final GeneralParameterValue param : group . values ( ) ) { String parameterName = param . getDescriptor ( ) . getName ( ) . getCode ( ) ; final int s = parameterName . lastIndexOf ( '[' ) ; if ( s >= 0 ) { parameterName = parameterName . substring ( 0 , s ) ; } final Integer count = names . remove ( parameterName ) ; if ( count != null ) { final int n = count - 1 ; if ( n != 0 ) { assertNull ( names . put ( parameterName , n ) ) ; } } else if ( ! isIgnorable ( parameterName ) ) { fail ( "Unknown \"" + parameterName + "\" parameter in \"" + projectionName + "\" projection." ) ; } } /*
             * Any remaining parameters in the set are parameter that should have been
             * declared in the GeoAPI wrappers but are not.
             */ assertTrue ( "Missing parameter in \"" + projectionName + "\" projection: " + names , names . isEmpty ( ) ) ; } }
Ensures that the parameter names are the same than the ones created by the UCAR library.
Ensures that the parameter names are the same than the ones created by the UCAR library .
// Not a map projection.