Search in sources :

Example 11 with DependsOnMethod

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());
}
Also used : DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) HashMap(java.util.HashMap) DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) ParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 12 with DependsOnMethod

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));
}
Also used : DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) HashMap(java.util.HashMap) DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) ParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 13 with DependsOnMethod

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);
}
Also used : DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) ParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) ParameterDescriptor(org.opengis.parameter.ParameterDescriptor) DefaultParameterDescriptor(org.apache.sis.parameter.DefaultParameterDescriptor) IdentityHashMap(java.util.IdentityHashMap) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) DefaultParameterDescriptor(org.apache.sis.parameter.DefaultParameterDescriptor) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 14 with DependsOnMethod

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));
}
Also used : DefaultParameterDescriptorGroup(org.apache.sis.parameter.DefaultParameterDescriptorGroup) ParameterDescriptorGroup(org.opengis.parameter.ParameterDescriptorGroup) GeneralParameterDescriptor(org.opengis.parameter.GeneralParameterDescriptor) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 15 with DependsOnMethod

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);
}
Also used : ReferenceIdentifier(org.opengis.referencing.ReferenceIdentifier) ImmutableIdentifier(org.apache.sis.metadata.iso.ImmutableIdentifier) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Aggregations

DependsOnMethod (org.apache.sis.test.DependsOnMethod)298 Test (org.junit.Test)296 ParameterValueGroup (org.opengis.parameter.ParameterValueGroup)27 ProjectedCRS (org.opengis.referencing.crs.ProjectedCRS)23 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)21 CoordinateOperation (org.opengis.referencing.operation.CoordinateOperation)21 Rectangle (java.awt.Rectangle)19 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)19 SimpleInternationalString (org.apache.sis.util.iso.SimpleInternationalString)18 GeographicCRS (org.opengis.referencing.crs.GeographicCRS)15 Random (java.util.Random)11 Matrix (org.opengis.referencing.operation.Matrix)11 HashMap (java.util.HashMap)10 IdentifiedObject (org.opengis.referencing.IdentifiedObject)8 ReferenceIdentifier (org.opengis.referencing.ReferenceIdentifier)8 MathTransform (org.opengis.referencing.operation.MathTransform)8 DefaultFeatureType (org.apache.sis.feature.DefaultFeatureType)7 DefaultFeatureTypeTest (org.apache.sis.feature.DefaultFeatureTypeTest)7 DirectPosition2D (org.apache.sis.geometry.DirectPosition2D)7 GeneralParameterDescriptor (org.opengis.parameter.GeneralParameterDescriptor)7