use of org.opengis.metadata.Identifier in project sis by apache.
the class PropertyAccessorTest method getSingletonCode.
/**
* Returns the code of the singleton identifier found in the given collection.
* This method verifies that the object is of the expected type.
*
* @param identifiers a singleton {@code Collection<Identifier>}.
* @return {@link Identifier#getCode()}.
*/
static String getSingletonCode(final Object identifiers) {
assertInstanceOf("identifiers", Collection.class, identifiers);
final Object identifier = getSingleton((Collection<?>) identifiers);
assertInstanceOf("identifier", Identifier.class, identifier);
return ((Identifier) identifier).getCode();
}
use of org.opengis.metadata.Identifier in project sis by apache.
the class ModifiableIdentifierMapTest method testHRefSubstitution.
/**
* Tests explicitely the special handling of {@code href} values.
*/
@Test
public void testHRefSubstitution() {
final List<Identifier> identifiers = new ArrayList<>();
final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
assertNull(map.put(HREF, "myHREF"));
assertEquals("Shall contain the entry we added.", "myHREF", map.get(HREF));
// Check the XLink object
final XLink link = map.getSpecialized(XLINK);
assertEquals("Added href shall be stored as XLink attribute.", "myHREF", String.valueOf(link.getHRef()));
assertEquals("Identifier list shall contain the XLink.", link.toString(), getSingleton(identifiers).getCode());
// Modidfy the XLink object directly
link.setHRef(URI.create("myNewHREF"));
assertEquals("Change in XLink shall be reflected in href.", "myNewHREF", map.get(HREF));
}
use of org.opengis.metadata.Identifier in project sis by apache.
the class ModifiableIdentifierMapTest method testUUIDs.
/**
* Tests with UUIDs.
*/
@Test
public void testUUIDs() {
final List<Identifier> identifiers = new ArrayList<>();
final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
final java.util.UUID id1 = fromString("434f3107-c6d2-4c8c-bb25-553f68641c5c");
final java.util.UUID id2 = fromString("42924124-032a-4dfe-b06e-113e3cb81cf0");
// Add first UUID.
assertNull(map.putSpecialized(UUID, id1));
// Replace UUID by a new one.
assertSame(id1, map.putSpecialized(UUID, id2));
}
use of org.opengis.metadata.Identifier in project sis by apache.
the class ModifiableIdentifierMapTest method testDuplicatedAuthorities.
/**
* Tests the handling of duplicated authorities.
*/
@Test
public void testDuplicatedAuthorities() {
final List<Identifier> identifiers = new ArrayList<>();
assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID1")));
assertTrue(identifiers.add(new IdentifierMapEntry(UUID, "myUUID")));
assertTrue(identifiers.add(new IdentifierMapEntry(ID, "myID2")));
final IdentifierMap map = new ModifiableIdentifierMap(identifiers);
assertEquals("Duplicated authorities shall be filtered.", 2, map.size());
assertEquals("Duplicated authorities shall still exist.", 3, identifiers.size());
assertEquals("myID1", map.get(ID));
assertEquals("myUUID", map.get(UUID));
final Iterator<Citation> it = map.keySet().iterator();
assertTrue(it.hasNext());
assertSame(ID, it.next());
it.remove();
assertTrue(it.hasNext());
assertSame(UUID, it.next());
assertFalse("Duplicated authority shall have been removed.", it.hasNext());
assertEquals(1, identifiers.size());
assertEquals(1, map.size());
}
use of org.opengis.metadata.Identifier in project sis by apache.
the class DefaultCitationTest method testIdentifierMap.
/**
* Tests the identifier map, which handles ISBN and ISSN codes in a special way.
*/
@Test
public void testIdentifierMap() {
final DefaultCitation citation = new DefaultCitation();
final Collection<Identifier> identifiers = citation.getIdentifiers();
final IdentifierMap identifierMap = citation.getIdentifierMap();
assertTrue("Expected an initially empty set of identifiers.", identifiers.isEmpty());
/*
* Set the ISBN code, and ensure that the the ISBN is reflected in the identifier map.
*/
citation.setISBN("MyISBN");
assertEquals("MyISBN", citation.getISBN());
assertEquals("ISBN code shall be included in the set of identifiers.", 1, identifiers.size());
assertEquals("{ISBN=“MyISBN”}", identifierMap.toString());
/*
* Set the identifiers with a list containing ISBN and ISSN codes.
* The ISBN code shall be ignored because and ISBN property was already set.
* The ISSN code shall be retained because it is a new code.
*/
assertNull("ISSN shall be initially null.", citation.getISSN());
citation.setIdentifiers(Arrays.asList(new DefaultIdentifier(Citations.NETCDF, "MyNetCDF"), new DefaultIdentifier(Citations.EPSG, "MyEPSG"), new DefaultIdentifier(Citations.ISBN, "NewISBN"), new DefaultIdentifier(Citations.ISSN, "MyISSN")));
assertEquals("The ISBN value shall have been overwritten.", "NewISBN", citation.getISBN());
assertEquals("The ISSN value shall have been added, because new.", "MyISSN", citation.getISSN());
assertEquals("{NetCDF=“MyNetCDF”, EPSG=“MyEPSG”, ISBN=“NewISBN”, ISSN=“MyISSN”}", identifierMap.toString());
}
Aggregations