use of org.apache.sis.test.DependsOnMethod 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.apache.sis.test.DependsOnMethod 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));
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CC_OperationParameterGroupTest method testMerge.
/**
* Tests the merge of unmarshalled descriptors with more complete descriptors.
* This operation is expected to create new descriptor instances as a result of the merges.
*
* @throws JAXBException if this method failed to create test data.
*/
@Test
@DependsOnMethod("testSubtitution")
public void testMerge() throws JAXBException {
final ParameterDescriptorGroup fromXML = unmarshal();
final ParameterDescriptor<?>[] fromValues = create(null);
final Map<GeneralParameterDescriptor, GeneralParameterDescriptor> replacements = new IdentityHashMap<>(4);
final GeneralParameterDescriptor[] merged = CC_OperationParameterGroup.merge(fromXML.descriptors(), fromValues.clone(), replacements);
assertNotSame(fromValues, merged);
/*
* "Longitude of natural origin" parameter should be the same.
*/
assertEquals("Number of parameters", 2, merged.length);
assertSame("Longitude of natural origin", fromValues[1], merged[1]);
/*
* "Latitude of natural origin" should be a new parameter, because we merged the remarks from the
* 'fromXML' descriptor with value class, unit and default value from the 'fromValue' descriptor.
*/
final GeneralParameterDescriptor incomplete = fromXML.descriptors().get(0);
final DefaultParameterDescriptor<?> fromValue = (DefaultParameterDescriptor<?>) fromValues[0];
final DefaultParameterDescriptor<?> complete = (DefaultParameterDescriptor<?>) merged[0];
assertNotSame("Latitude of natural origin", incomplete, complete);
assertNotSame("Latitude of natural origin", fromValue, complete);
assertSame("name", fromValue.getName(), complete.getName());
assertSame("remarks", incomplete.getRemarks(), complete.getRemarks());
assertEquals("valueClass", Double.class, complete.getValueClass());
assertSame("valueDomain", fromValue.getValueDomain(), complete.getValueDomain());
/*
* All references to 'fromValue' will need to be replaced by references to 'complete'.
*/
assertEquals("replacements", Collections.singletonMap(fromValue, complete), replacements);
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CC_OperationParameterGroupTest method testGroup.
/**
* Tests {@link CC_OperationMethod#group(Identifier, GeneralParameterDescriptor[])}.
*
* @throws JAXBException if this method failed to create test data.
*/
@Test
@DependsOnMethod("testMerge")
public void testGroup() throws JAXBException {
// From XML
ParameterDescriptorGroup group = unmarshal();
List<GeneralParameterDescriptor> descriptors = group.descriptors();
// Merge with the parameters defined in Mercator1SP class
group = CC_OperationMethod.group(group.getName(), descriptors.toArray(new GeneralParameterDescriptor[descriptors.size()]));
descriptors = group.descriptors();
assertSame("name", group.getName(), group.getName());
assertEquals("descriptors.size", 2, descriptors.size());
verifyMethodParameter(Mercator1SP.LATITUDE_OF_ORIGIN, REMARK, (ParameterDescriptor<?>) descriptors.get(0));
verifyMethodParameter(Mercator1SP.LONGITUDE_OF_ORIGIN, null, (ParameterDescriptor<?>) descriptors.get(1));
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class CodeTest method testForIdentifiedObject.
/**
* Tests {@link Code#forIdentifiedObject(Class, Iterable)}.
*/
@Test
@DependsOnMethod("testWithVersion")
public void testForIdentifiedObject() {
final ReferenceIdentifier id = new ImmutableIdentifier(Citations.EPSG, "EPSG", "4326", "8.2", null);
final Code value = Code.forIdentifiedObject(GeographicCRS.class, Collections.singleton(id));
assertNotNull(value);
assertEquals("codeSpace", Constants.IOGP, value.codeSpace);
assertEquals("code", "urn:ogc:def:crs:EPSG:8.2:4326", value.code);
}
Aggregations