use of org.opengis.parameter.ParameterDescriptorGroup in project sis by apache.
the class TensorValuesTest method testDescriptor.
/**
* Tests {@link TensorValues#descriptor(String)}.
*/
@Test
public void testDescriptor() {
final Double N0 = 0.0;
final Double N1 = 1.0;
final Integer N3 = 3;
final ParameterValueGroup group = createWKT1();
final ParameterDescriptorGroup d = group.getDescriptor();
assertDescriptorEquals(NUM_ROW, N3, d.descriptor(NUM_ROW));
assertDescriptorEquals(NUM_COL, N3, d.descriptor(NUM_COL));
assertDescriptorEquals("elt_0_0", N1, d.descriptor("elt_0_0"));
assertDescriptorEquals("elt_0_1", N0, d.descriptor("elt_0_1"));
assertDescriptorEquals("elt_0_2", N0, d.descriptor("elt_0_2"));
assertDescriptorEquals("elt_1_0", N0, d.descriptor("elt_1_0"));
assertDescriptorEquals("elt_1_1", N1, d.descriptor("elt_1_1"));
assertDescriptorEquals("elt_1_2", N0, d.descriptor("elt_1_2"));
assertDescriptorEquals("elt_2_0", N0, d.descriptor("elt_2_0"));
assertDescriptorEquals("elt_2_1", N0, d.descriptor("elt_2_1"));
assertDescriptorEquals("elt_2_2", N1, d.descriptor("elt_2_2"));
/*
* Same test than above, but using the EPSG or pseudo-EPSG names.
*/
assertDescriptorEquals("elt_0_0", N1, d.descriptor("A0"));
assertDescriptorEquals("elt_0_1", N0, d.descriptor("A1"));
assertDescriptorEquals("elt_0_2", N0, d.descriptor("A2"));
assertDescriptorEquals("elt_1_0", N0, d.descriptor("B0"));
assertDescriptorEquals("elt_1_1", N1, d.descriptor("B1"));
assertDescriptorEquals("elt_1_2", N0, d.descriptor("B2"));
assertDescriptorEquals("elt_2_0", N0, d.descriptor("C0"));
assertDescriptorEquals("elt_2_1", N0, d.descriptor("C1"));
assertDescriptorEquals("elt_2_2", N1, d.descriptor("C2"));
/*
* If we reduce the matrix size, than it shall not be possible
* anymore to get the descriptor in the row that we removed.
*/
group.parameter(NUM_COL).setValue(2);
try {
d.descriptor("elt_2_2");
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));
}
}
use of org.opengis.parameter.ParameterDescriptorGroup in project sis by apache.
the class CC_GeneralOperationParameterTest method testGroupMergeBecauseDifferentProperties.
/**
* Tests case where the unmarshalled parameter group needs to be merged with the complete parameter group.
* The reason for the group merge in this test is because the unmarshalled parameters have different remarks
* or different obligation.
*
* @throws JAXBException if this method failed to create test data.
*/
@Test
@DependsOnMethod({ "testGroupSubstitution", "testParameterMerge" })
public void testGroupMergeBecauseDifferentProperties() throws JAXBException {
final Map<String, String> properties = new HashMap<>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2, unmarshal("Parameter A", "Remarks A."), unmarshal("Parameter B", "Remarks B."), unmarshal("Parameter C", "Remarks C."));
assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY, "More details here."));
final ParameterDescriptorGroup complete = new DefaultParameterDescriptorGroup(properties, 1, 2, create("Parameter A", "Remarks A.", true, 3), create("Parameter B", "Remarks B.", false, 4), create("Parameter C", "Different.", false, 5), create("Parameter D", "Remarks D.", false, 6));
final ParameterDescriptorGroup merged = (ParameterDescriptorGroup) CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame(complete, provided);
assertSame("name", complete.getName(), merged.getName());
assertSame("remarks", complete.getRemarks(), merged.getRemarks());
assertEquals("minimumOccurs", 1, merged.getMinimumOccurs());
assertEquals("maximumOccurs", 2, merged.getMaximumOccurs());
final Iterator<GeneralParameterDescriptor> itc = complete.descriptors().iterator();
final Iterator<GeneralParameterDescriptor> itm = merged.descriptors().iterator();
// Not same because different obligation.
verifyParameter(itc.next(), itm.next(), false, "Remarks A.");
// Same ParameterDescriptor instance.
verifyParameter(itc.next(), itm.next(), true, "Remarks B.");
// Not same because different remarks.
verifyParameter(itc.next(), itm.next(), false, "Remarks C.");
assertTrue("Missing descriptor.", itc.hasNext());
assertFalse("Unexpected descriptor.", itm.hasNext());
}
use of org.opengis.parameter.ParameterDescriptorGroup in project sis by apache.
the class CC_GeneralOperationParameterTest method testGroupMergeBecauseExtraParameter.
/**
* Tests case where the unmarshalled parameter group needs to be merged with the complete parameter group.
* The reason for the group merge in this test is because the unmarshalled parameters have a parameter not
* present in the "complete" group.
*
* @throws JAXBException if this method failed to create test data.
*/
@Test
@DependsOnMethod("testGroupMergeBecauseDifferentProperties")
public void testGroupMergeBecauseExtraParameter() throws JAXBException {
final Map<String, String> properties = new HashMap<>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2, unmarshal("Parameter A", "Remarks A."), unmarshal("Parameter B", "Remarks B."), unmarshal("Parameter C", "Remarks C."));
assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY, "More details here."));
final ParameterDescriptorGroup complete = new DefaultParameterDescriptorGroup(properties, 1, 2, create("Parameter A", "Remarks A.", false, 3), create("Parameter C", "Remarks C.", false, 4));
loggings.assertNoUnexpectedLog();
final ParameterDescriptorGroup merged = (ParameterDescriptorGroup) CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame(complete, provided);
assertSame("name", complete.getName(), merged.getName());
assertSame("remarks", complete.getRemarks(), merged.getRemarks());
assertEquals("minimumOccurs", 1, merged.getMinimumOccurs());
assertEquals("maximumOccurs", 2, merged.getMaximumOccurs());
loggings.assertNextLogContains("Parameter B", "Group");
loggings.assertNoUnexpectedLog();
final Iterator<GeneralParameterDescriptor> itc = complete.descriptors().iterator();
final Iterator<GeneralParameterDescriptor> itm = merged.descriptors().iterator();
verifyParameter(itc.next(), itm.next(), true, "Remarks A.");
final GeneralParameterDescriptor extra = itm.next();
assertEquals("name", "Parameter B", extra.getName().getCode());
assertEquals("remark", "Remarks B.", extra.getRemarks().toString());
verifyParameter(itc.next(), itm.next(), true, "Remarks C.");
assertFalse("Unexpected descriptor.", itc.hasNext());
assertFalse("Unexpected descriptor.", itm.hasNext());
}
use of org.opengis.parameter.ParameterDescriptorGroup in project sis by apache.
the class CC_GeneralOperationParameterTest method testGroupMergeBecauseMissingParameter.
/**
* Tests case where the unmarshalled parameter group needs to be merged with the complete parameter group.
* The reason for the group merge in this test is because the unmarshalled parameters is missing a mandatory
* parameter.
*
* @throws JAXBException if this method failed to create test data.
*/
@Test
@DependsOnMethod("testGroupMergeBecauseDifferentProperties")
public void testGroupMergeBecauseMissingParameter() throws JAXBException {
final Map<String, String> properties = new HashMap<>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2, unmarshal("Parameter A", null), unmarshal("Parameter C", null));
assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY, "More details here."));
final ParameterDescriptorGroup complete = new DefaultParameterDescriptorGroup(properties, 1, 2, create("Parameter A", null, false, 3), create("Parameter B", null, true, 4), create("Parameter C", null, false, 5));
final ParameterDescriptorGroup merged = (ParameterDescriptorGroup) CC_GeneralOperationParameter.merge(provided, complete);
assertNotSame(complete, provided);
assertSame("name", complete.getName(), merged.getName());
assertSame("remarks", complete.getRemarks(), merged.getRemarks());
assertEquals("minimumOccurs", 1, merged.getMinimumOccurs());
assertEquals("maximumOccurs", 2, merged.getMaximumOccurs());
final Iterator<GeneralParameterDescriptor> itc = complete.descriptors().iterator();
final Iterator<GeneralParameterDescriptor> itm = merged.descriptors().iterator();
verifyParameter(itc.next(), itm.next(), true, null);
// Skip the parameter which is missing in the unmarshalled descriptor group.
assertEquals("Missing parameter.", "Parameter B", itc.next().getName().getCode());
verifyParameter(itc.next(), itm.next(), true, null);
assertFalse("Unexpected descriptor.", itc.hasNext());
assertFalse("Unexpected descriptor.", itm.hasNext());
}
use of org.opengis.parameter.ParameterDescriptorGroup in project sis by apache.
the class CC_GeneralOperationParameterTest method testGroupSubstitution.
/**
* Tests case where the unmarshalled parameter group can be substituted by the complete parameter group.
* The cases tested in this method should not create any new {@link ParameterDescriptorGroup} instance.
*
* @throws JAXBException if this method failed to create test data.
*/
@Test
@DependsOnMethod("testParameterSubstitution")
public void testGroupSubstitution() throws JAXBException {
final Map<String, String> properties = new HashMap<>(4);
assertNull(properties.put(DefaultParameterDescriptor.NAME_KEY, "Group"));
final ParameterDescriptorGroup provided = new DefaultParameterDescriptorGroup(properties, 1, 2, unmarshal("Parameter A", null), unmarshal("Parameter B", "Remarks B."), unmarshal("Parameter C", null));
assertNull(properties.put(DefaultParameterDescriptor.REMARKS_KEY, "More details here."));
final ParameterDescriptorGroup complete = new DefaultParameterDescriptorGroup(properties, 1, 2, create("Parameter A", "Remarks A.", false, 3), create("Parameter B", "Remarks B.", false, 4), create("Parameter C", "Remarks C.", false, 5), create("Parameter D", "Remarks D.", false, 6));
assertSame(complete, CC_GeneralOperationParameter.merge(provided, complete));
}
Aggregations