use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class TensorValuesTest method testValues.
/**
* Tests {@link TensorValues#values()}.
*/
@Test
@DependsOnMethod("testParameter")
public void testValues() {
final ParameterValueGroup group = createWKT1();
group.parameter(NUM_ROW).setValue(2);
group.parameter(NUM_COL).setValue(3);
List<GeneralParameterValue> values = group.values();
assertValueEquals(NUM_ROW, 2, values.get(0));
assertValueEquals(NUM_COL, 3, values.get(1));
assertEquals("size", 2, values.size());
/*
* Above list had no explicit parameters, since all of them had their default values.
* Now set some parameters to different values. Those parameters should now appear in
* the list.
*/
group.parameter("elt_0_1").setValue(8);
group.parameter("elt_1_1").setValue(7);
group.parameter("elt_1_2").setValue(6);
values = group.values();
assertValueEquals(NUM_ROW, 2, values.get(0));
assertValueEquals(NUM_COL, 3, values.get(1));
assertValueEquals("elt_0_1", 8.0, values.get(2));
assertValueEquals("elt_1_1", 7.0, values.get(3));
assertValueEquals("elt_1_2", 6.0, values.get(4));
assertEquals("size", 5, values.size());
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class UnmodifiableParameterValueTest method testGetValue.
/**
* Verifies that {@link UnmodifiableParameterValue#getValue()} can clone the value.
*/
@Test
@DependsOnMethod("testCreate")
public void testGetValue() {
final ParameterValue<Date> modifiable = DefaultParameterDescriptorTest.createSimpleOptional("Time reference", Date.class).createValue();
modifiable.setValue(date("1994-01-01 00:00:00"));
/*
* Create and validate an unmodifiable parameter,
* then verify that the values are not the same.
*/
final DefaultParameterValue<Date> unmodifiable = assertEquivalent(modifiable);
final Date t1 = modifiable.getValue();
final Date t2 = unmodifiable.getValue();
assertNotSame("Date should be cloned.", t1, t2);
assertEquals(t1, t2);
/*
* Verify that cloning the parameter also clone its value.
*/
final DefaultParameterValue<Date> clone = unmodifiable.clone();
assertEquals(DefaultParameterValue.class, clone.getClass());
final Date t3 = clone.getValue();
assertNotSame(t1, t3);
assertNotSame(t2, t3);
assertEquals(t1, t3);
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class AbstractIdentifiedObjectTest method testWithSingleIdentifier.
/**
* Tests the {@link AbstractIdentifiedObject#AbstractIdentifiedObject(Map)} constructor
* with only one identifier. The methods of interest for this test are:
*
* <ul>
* <li>{@link AbstractIdentifiedObject#getIdentifiers()}</li>
* <li>{@link AbstractIdentifiedObject#getIdentifier()}</li>
* <li>{@link AbstractIdentifiedObject#getID()}</li>
* </ul>
*/
@Test
@DependsOnMethod("testWithoutIdentifier")
public void testWithSingleIdentifier() {
final ReferenceIdentifier identifier = new ImmutableIdentifier(null, "EPSG", "7019");
final Set<ReferenceIdentifier> identifiers = Collections.singleton(identifier);
final AbstractIdentifiedObject object = new AbstractIdentifiedObject(properties(identifiers));
final ReferenceIdentifier gmlId = validate(object, identifiers, "epsg-7019");
assertNotNull("gmlId", gmlId);
assertEquals("gmlId.codespace", "EPSG", gmlId.getCodeSpace());
assertEquals("gmlId.code", "7019", gmlId.getCode());
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class AbstractReferenceSystemTest method testWKT.
/**
* Tests WKT formatting with a name that contains the quote character and optional information.
* We test that the closing quote character is doubled and the optional information properly formatted.
*/
@Test
@DependsOnMethod("testCreateFromMap")
public void testWKT() {
final Map<String, Object> properties = new HashMap<>(8);
assertNull(properties.put(NAME_KEY, "My “object”."));
assertNull(properties.put(SCOPE_KEY, "Large scale topographic mapping and cadastre."));
assertNull(properties.put(REMARKS_KEY, "注です。"));
assertNull(properties.put(IDENTIFIERS_KEY, new ImmutableIdentifier(Citations.EPSG, "EPSG", "4326", "8.2", null)));
assertNull(properties.put(DOMAIN_OF_VALIDITY_KEY, new DefaultExtent("Netherlands offshore.", new DefaultGeographicBoundingBox(2.54, 6.40, 51.43, 55.77), new DefaultVerticalExtent(10, 1000, VerticalCRSMock.DEPTH), // TODO: needs sis-temporal module for testing that one.
new DefaultTemporalExtent())));
final AbstractReferenceSystem object = new AbstractReferenceSystem(properties);
assertTrue(object.toString(Convention.WKT1).startsWith("ReferenceSystem[\"My “object”.\", AUTHORITY[\"EPSG\", \"4326\"]]"));
assertWktEquals(Convention.WKT1, "ReferenceSystem[“My \"object\".”, AUTHORITY[“EPSG”, “4326”]]", object);
assertWktEquals(Convention.WKT2, // Quotes replaced
"ReferenceSystem[“My \"object\".”,\n" + " SCOPE[“Large scale topographic mapping and cadastre.”],\n" + " AREA[“Netherlands offshore.”],\n" + " BBOX[51.43, 2.54, 55.77, 6.40],\n" + " VERTICALEXTENT[-1000, -10, LENGTHUNIT[“metre”, 1]],\n" + " ID[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" + " REMARK[“注です。”]]", object);
assertWktEquals(Convention.WKT2_SIMPLIFIED, "ReferenceSystem[“My \"object\".”,\n" + " Scope[“Large scale topographic mapping and cadastre.”],\n" + " Area[“Netherlands offshore.”],\n" + " BBox[51.43, 2.54, 55.77, 6.40],\n" + " VerticalExtent[-1000, -10],\n" + " Id[“EPSG”, 4326, “8.2”, URI[“urn:ogc:def:referenceSystem:EPSG:8.2:4326”]],\n" + " Remark[“注です。”]]", object);
assertWktEquals(Convention.INTERNAL, // Quote doubled
"ReferenceSystem[“My “object””.”,\n" + " Scope[“Large scale topographic mapping and cadastre.”],\n" + " Area[“Netherlands offshore.”],\n" + " BBox[51.43, 2.54, 55.77, 6.40],\n" + " VerticalExtent[-1000, -10],\n" + " Id[“EPSG”, 4326, “8.2”],\n" + " Remark[“注です。”]]", object);
}
use of org.apache.sis.test.DependsOnMethod in project sis by apache.
the class BuilderTest method testAddNameWithScope.
/**
* Tests {@link Builder#addName(Citation, CharSequence)} and {@link Builder#addName(CharSequence)} with codespace.
*/
@Test
@DependsOnMethod({ "testAddName", "testSetCodeSpace" })
public void testAddNameWithScope() {
final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
// Expected values to be used later in the test.
final String name = "Mercator (variant A)";
final GenericName alias1 = factory.createLocalName(scope(factory, "EPSG"), "Mercator (1SP)");
final GenericName alias2 = new NamedIdentifier(Citations.OGC, "Mercator_1SP");
final GenericName alias3 = new NamedIdentifier(Citations.GEOTIFF, "CT_Mercator");
assertTrue("That name should not have a scope.", alias3.scope().isGlobal());
assertTrue("That name should not have a scope.", alias2.scope().isGlobal());
assertFalse("That name should be in EPSG scope.", alias1.scope().isGlobal());
assertEquals("EPSG", alias1.scope().name().toString());
assertEquals("Mercator (1SP)", alias1.toString());
assertEquals("OGC:Mercator_1SP", alias2.toString());
assertEquals("GeoTIFF:CT_Mercator", alias3.toString());
// The test.
final BuilderMock builder = createMercator(true, false);
assertEquals(name, builder.getName());
assertArrayEquals(new GenericName[] { alias1, alias2, alias3 }, builder.getAliases());
}
Aggregations