Search in sources :

Example 61 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class MetadataStandardTest method testEquals.

/**
 * Tests the {@link MetadataStandard#equals(Object, Object, ComparisonMode)} method.
 */
@Test
@DependsOnMethod("testGetAccessor")
public void testEquals() {
    standard = MetadataStandard.ISO_19115;
    // Self equality test
    DefaultCitation instance = HardCodedCitations.EPSG;
    assertFalse(standard.equals(instance, HardCodedCitations.SIS, ComparisonMode.STRICT));
    assertTrue(standard.equals(instance, HardCodedCitations.EPSG, ComparisonMode.STRICT));
    // Test comparison with a copy
    instance = new DefaultCitation(HardCodedCitations.EPSG);
    assertFalse(standard.equals(instance, HardCodedCitations.SIS, ComparisonMode.STRICT));
    assertTrue(standard.equals(instance, HardCodedCitations.EPSG, ComparisonMode.STRICT));
    // test comparison with a modified copy
    instance.setTitle(new SimpleInternationalString("A dummy title"));
    assertFalse(standard.equals(instance, HardCodedCitations.EPSG, ComparisonMode.STRICT));
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 62 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class MetadataStandardTest method testEqualsOnCyclicMetadata.

/**
 * Tests the {@link MetadataStandard#equals(Object, Object, ComparisonMode)} method on an object
 * having cyclic associations. In absence of safety guard against infinite recursivity, this test
 * would produce {@link StackOverflowError}.
 */
@Test
@DependsOnMethod("testEquals")
public void testEqualsOnCyclicMetadata() {
    final DefaultAcquisitionInformation p1 = createCyclicMetadata();
    final DefaultAcquisitionInformation p2 = createCyclicMetadata();
    assertTrue("equals", p1.equals(p2));
    final DefaultPlatform platform = (DefaultPlatform) getSingleton(p2.getPlatforms());
    final DefaultInstrument instrument = (DefaultInstrument) getSingleton(platform.getInstruments());
    instrument.setType(new SimpleInternationalString("An other instrument type."));
    assertFalse("equals", p1.equals(p2));
}
Also used : DefaultAcquisitionInformation(org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) DefaultPlatform(org.apache.sis.metadata.iso.acquisition.DefaultPlatform) DefaultInstrument(org.apache.sis.metadata.iso.acquisition.DefaultInstrument) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 63 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class PropertyAccessorTest method testSetCollection.

/**
 * Tests the {@link PropertyAccessor#set(int, Object, Object, int)} method when the value
 * is a collection. The new collection shall replace the previous one (no merge expected).
 * The metadata object created by this test after the replacement is:
 *
 * {@preformat text
 *   DefaultCitation
 *     ├─Title……………………………………………………… Ignored title
 *     ├─Alternate title (1 of 2)…… New title 1
 *     └─Alternate title (2 of 2)…… New title 2
 * }
 *
 * @see #testSetInAppendMode()
 */
@Test
@DependsOnMethod("testSet")
public void testSetCollection() {
    final DefaultCitation instance = new DefaultCitation("Ignored title");
    final List<InternationalString> oldTitles = Arrays.<InternationalString>asList(new SimpleInternationalString("Old title 1"), new SimpleInternationalString("Old title 2"));
    final List<InternationalString> newTitles = Arrays.<InternationalString>asList(new SimpleInternationalString("New title 1"), new SimpleInternationalString("New title 2"));
    // Set the alternate titles.
    instance.setAlternateTitles(oldTitles);
    final PropertyAccessor accessor = createPropertyAccessor();
    final int index = accessor.indexOf("alternateTitles", true);
    final Object oldValue = accessor.set(index, instance, newTitles, RETURN_PREVIOUS);
    final Object newValue = accessor.get(index, instance);
    // Verify the values.
    assertEquals("set(…, RETURN_PREVIOUS)", oldTitles, oldValue);
    assertEquals("get(…)", newTitles, newValue);
    assertSame("alternateTitles", newValue, instance.getAlternateTitles());
    assertTitleEquals("title", "Ignored title", instance);
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) InternationalString(org.opengis.util.InternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) IdentifiedObject(org.opengis.referencing.IdentifiedObject) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 64 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class PropertyAccessorTest method testGet.

/**
 * Tests the {@link PropertyAccessor#get(int, Object)} method on the {@link HardCodedCitations#ISO_19111} constant.
 * The metadata object read by this test is:
 *
 * {@preformat text
 *   DefaultCitation
 *     ├─Title…………………………………… International Organization for Standardization
 *     ├─Alternate title………… ISO 19111
 *     ├─Identifier
 *     │   ├─Code…………………………… 19111
 *     │   └─Code space…………… ISO
 *     └─Presentation form…… Document digital
 * }
 */
@Test
@DependsOnMethod("testConstructor")
public void testGet() {
    final DefaultCitation instance = HardCodedCitations.ISO_19111;
    final PropertyAccessor accessor = createPropertyAccessor();
    // Singleton value (not a collection)
    final Object title = accessor.get(accessor.indexOf("title", true), instance);
    assertInstanceOf("title", InternationalString.class, title);
    assertEquals("title", "Spatial referencing by coordinates", title.toString());
    // Collection of InternationalStrings
    final Object alternateTitles = accessor.get(accessor.indexOf("alternateTitles", true), instance);
    assertInstanceOf("alternateTitles", Collection.class, alternateTitles);
    assertEquals("alternateTitles", "ISO 19111", getSingleton((Collection<?>) alternateTitles).toString());
    // Collection of Identifiers
    final Object identifiers = accessor.get(accessor.indexOf("identifiers", true), instance);
    assertEquals("19111", getSingletonCode(identifiers));
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) IdentifiedObject(org.opengis.referencing.IdentifiedObject) Test(org.junit.Test) DependsOnMethod(org.apache.sis.test.DependsOnMethod)

Example 65 with DependsOnMethod

use of org.apache.sis.test.DependsOnMethod in project sis by apache.

the class PropertyAccessorTest method testSet.

/**
 * Tests the {@link PropertyAccessor#set(int, Object, Object, int)} method
 * with a value to be stored <cite>as-is</cite> (without conversion).
 * The metadata object created by this test is:
 *
 * {@preformat text
 *   DefaultCitation
 *     ├─Title………………………… Some title
 *     ├─Identifier
 *     │   ├─Code………………… Some ISBN code
 *     │   └─Authority
 *     │       └─Title…… ISBN
 *     └─ISBN…………………………… Some ISBN code
 * }
 */
@Test
@DependsOnMethod("testGet")
public void testSet() {
    final DefaultCitation instance = new DefaultCitation();
    final PropertyAccessor accessor = createPropertyAccessor();
    Object newValue;
    int index;
    newValue = new SimpleInternationalString("Some title");
    index = accessor.indexOf("title", true);
    assertNull("title", accessor.set(index, instance, newValue, RETURN_PREVIOUS));
    assertSame("title", newValue, accessor.get(index, instance));
    assertSame("title", newValue, instance.getTitle());
    newValue = "Some ISBN code";
    index = accessor.indexOf("ISBN", true);
    assertNull("ISBN", accessor.set(index, instance, newValue, RETURN_PREVIOUS));
    assertSame("ISBN", newValue, accessor.get(index, instance));
    assertSame("ISBN", newValue, instance.getISBN());
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) SimpleInternationalString(org.apache.sis.util.iso.SimpleInternationalString) IdentifiedObject(org.opengis.referencing.IdentifiedObject) 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