/** * Always throws an exception, since JAI's {@linkplain ParameterList parameter list} don't have * subgroups. */ public ParameterValueGroup addGroup(final String name) throws ParameterNotFoundException { throw new ParameterNotFoundException( Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name), name); }
if (cause != null) try { exception.initCause(cause); } catch (IllegalStateException ignore) {
throw (ParameterNotFoundException) new ParameterNotFoundException(Resources.format( Resources.Keys.ParameterNotFound_2, caller.getName(), name), name).initCause(cause);
} catch (ParameterNotFoundException e) { assertEquals("4", e.getParameterName()); assertNotNull(e.getMessage()); } catch (ParameterNotFoundException e) { assertEquals("3", e.getParameterName()); } catch (ParameterNotFoundException e) { assertEquals("3", e.getParameterName()); } catch (ParameterNotFoundException e) { assertEquals("2", e.getParameterName()); } catch (ParameterNotFoundException e) { assertEquals("2", e.getParameterName());
throw param.parseFailed( exception, Errors.format(ErrorKeys.UNEXPECTED_PARAMETER_$1, exception.getParameterName()));
/** * Tests creation of an {@link UnmodifiableParameterValueGroup} and verify the values. */ @Test public void testCreate() { ParameterValueGroup group = DefaultParameterDescriptorGroupTest.M1_M1_O1_O2.createValue(); group.parameter("Mandatory 1").setValue(5); group.parameter("Optional 3") .setValue(8); group = UnmodifiableParameterValueGroup.create(group); assertEquals("values.size()", 3, group.values().size()); assertEquals("values[0].name", "Mandatory 1", group.values().get(0).getDescriptor().getName().toString()); assertEquals("values[1].name", "Mandatory 2", group.values().get(1).getDescriptor().getName().toString()); assertEquals("values[2].name", "Optional 3", group.values().get(2).getDescriptor().getName().toString()); assertEquals("values[0].value", 5, group.parameter("Mandatory 1").getValue()); assertEquals("values[1].value", 10, group.parameter("Mandatory 2").getValue()); assertEquals("values[2].value", 8, group.parameter("Optional 3") .getValue()); try { group.groups("dummy"); fail("Shall not return non-existent groups."); } catch (ParameterNotFoundException e) { assertTrue(e.getMessage().contains("Test group")); assertTrue(e.getMessage().contains("dummy")); } }
/** * Creates a transform from a group of parameters. All cartographic projections * created through this method will have the following properties: * * <ul> * <li>Converts from (<var>longitude</var>,<var>latitude</var>) coordinates to (<var>x</var>,<var>y</var>).</li> * <li>All angles are assumed to be degrees, and all distances are assumed to be meters.</li> * <li>The domain shall be a subset of {[-180,180)×(-90,90)}.</li> * </ul> * * @param parameters the parameter values. * @return the parameterized transform. * @throws FactoryException if the object creation failed. This exception is thrown * if some required parameter has not been supplied, or has illegal value. */ @Override public MathTransform createParameterizedTransform(final ParameterValueGroup parameters) throws FactoryException { final String method = parameters.getDescriptor().getName().getCode(); final ProjectionProvider<?> provider = providers.get(method); if (provider != null) try { return new NetcdfProjection(provider.createProjection(parameters), provider, null, null); } catch (ParameterNotFoundException e) { throw new FactoryException("Illegal parameters for the \"" + method + "\" projection: " + e.getLocalizedMessage(), e); } throw new NoSuchIdentifierException("Projection \"" + method + "\" not found.", method); }
throw (ParameterNotFoundException) new ParameterNotFoundException(Resources.format( Resources.Keys.ParameterNotFound_2, caller.getName(), name), name).initCause(cause);
/** * Verifies that {@link DefaultParameterDescriptorGroup#descriptor(String)} can detect ambiguities. */ @Test public void testAmbiguityDetection() { try { M1_M1_O1_O2.descriptor("Ambiguity"); fail("“Ambiguity” shall not be accepted since 2 parameters have this alias."); } catch (ParameterNotFoundException e) { final String message = e.getMessage(); assertEquals(message, "Ambiguity", e.getParameterName()); assertTrue (message, message.contains("Ambiguity")); assertTrue (message, message.contains("Mandatory 1")); assertTrue (message, message.contains("Optional 4")); } }
new String[] {e.getParameterName()}, param.offset).initCause(e); } catch (InvalidParameterValueException e) { throw (ParseException) new ParseException(e.getLocalizedMessage(), param.offset).initCause(e);
/** * Tests {@link ContextualParameters#parameter(String)} and {@link ContextualParameters#values()}. */ @Test public void testParameters() { final ContextualParameters p = create(1, 1); assertTrue("values().isEmpty()", p.values().isEmpty()); assertTrue("normalize.isIdentity()", p.getMatrix(ContextualParameters.MatrixRole.NORMALIZATION).isIdentity()); assertTrue("denormalize.isIdentity()", p.getMatrix(ContextualParameters.MatrixRole.DENORMALIZATION).isIdentity()); assertTrue("normalize.isIdentity()", p.getMatrix(ContextualParameters.MatrixRole.INVERSE_NORMALIZATION).isIdentity()); assertTrue("denormalize.isIdentity()", p.getMatrix(ContextualParameters.MatrixRole.INVERSE_DENORMALIZATION).isIdentity()); final ParameterValue<?> p1 = p.parameter("Mandatory 1"); final ParameterValue<?> p2 = p.parameter("Mandatory 2"); try { p.parameter("Mandatory 3"); fail("Shall not find a non-existent parameter."); } catch (ParameterNotFoundException e) { // This is the expected exception. final String message = e.getMessage(); assertTrue(message, message.contains("Mandatory 3")); } assertNotSame(p1, p2); assertSame(p1, p.parameter("Mandatory 1")); assertSame(p2, p.parameter("Mandatory 2")); assertEquals("values().size()", 2, p.values().size()); assertArrayEquals("values.toArray()", new ParameterValue<?>[] {p1, p2}, p.values().toArray()); }
/** * Always throws an exception, since JAI's {@linkplain ParameterList parameter list} don't have * subgroups. */ public List<ParameterValueGroup> groups(final String name) throws ParameterNotFoundException { throw new ParameterNotFoundException( Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name), name); }
throw (ParameterNotFoundException) new ParameterNotFoundException(Resources.format( Resources.Keys.ParameterNotFound_2, getName(), name), name).initCause(cause);
/** * Tests {@link DefaultParameterDescriptorGroup#descriptor(String)}. */ @Test public void testDescriptor() { final DefaultParameterDescriptorGroup group = M1_M1_O1_O2; final List<GeneralParameterDescriptor> descriptors = group.descriptors(); assertEquals("name", "Test group", group.getName().getCode()); assertEquals("size", 4, descriptors.size()); assertSame("descriptor(“Mandatory 1”)", descriptors.get(0), group.descriptor("Mandatory 1")); assertSame("descriptor(“Optional 3”)", descriptors.get(2), group.descriptor("Optional 3")); assertSame("descriptor(“Optional 4”)", descriptors.get(3), group.descriptor("Optional 4")); assertSame("descriptor(“Mandatory 2”)", descriptors.get(1), group.descriptor("Mandatory 2")); assertSame("descriptor(“Mandatory 2”)", descriptors.get(1), group.descriptor("Alias 2")); assertSame("descriptor(“Optional 3”)", descriptors.get(2), group.descriptor("Alias 3")); try { group.descriptor("Alias 1"); fail("“Alias 1” is not a parameter for this group."); } catch (ParameterNotFoundException e) { final String message = e.getMessage(); assertEquals(message, "Alias 1", e.getParameterName()); assertTrue (message, message.contains("Alias 1")); assertTrue (message, message.contains("Test group")); } }
new String[] {e.getParameterName()}, param.offset).initCause(e); } catch (InvalidParameterValueException e) { throw (ParseException) new ParseException(e.getLocalizedMessage(), param.offset).initCause(e);
fail("elt_2_2 should not exist."); } catch (ParameterNotFoundException e) { final String message = e.getMessage(); assertTrue(message, message.contains("elt_2_2")); assertTrue(message, message.contains(GROUP_NAME));
if (cause != null) try { exception.initCause(cause); } catch (IllegalStateException ignore) {
((ParameterDescriptorGroup) descriptor).descriptor(name); if (!(check instanceof ParameterDescriptorGroup)) { throw new ParameterNotFoundException( Errors.format(ErrorKeys.MISSING_PARAMETER_$1, name), name);
throw (ParameterNotFoundException) new ParameterNotFoundException(Resources.format( Resources.Keys.ParameterNotFound_2, getName(), name), name).initCause(cause);
fail("elt_2_2 should not exist."); } catch (ParameterNotFoundException e) { final String message = e.getMessage(); assertTrue(message, message.contains("elt_2_2")); assertTrue(message, message.contains(GROUP_NAME));