/**
* Tests the {@link PropertyMap} implementation.
*/
@Test
public void testMap() {
final Citation citation = new CitationImpl(Citations.EPSG);
final Map<String,Object> map = MetadataStandard.ISO_19115.asMap(citation);
assertFalse(map.isEmpty());
assertTrue (map.size() > 1);
final Set<String> keys = map.keySet();
assertTrue ("Property exists and should be defined.", keys.contains("title"));
assertFalse("Property exists but undefined for Citations.EPSG.", keys.contains("ISBN"));
assertFalse("Property do not exists.", keys.contains("dummy"));
final String s = keys.toString();
assertTrue (s.indexOf("title") >= 0);
assertTrue (s.indexOf("identifiers") >= 0);
assertFalse(s.indexOf("ISBN") >= 0);
final Object identifiers = map.get("identifiers");
assertTrue(identifiers instanceof Collection);
assertTrue(PropertyAccessorTest.containsEPSG(identifiers));
final Map<String,Object> copy = new HashMap<String,Object>(map);
assertEquals(map, copy);
// Note: AbstractCollection do not defines hashCode(); we have to wraps in a HashSet.
final int hashCode = citation.hashCode();
assertEquals("hashCode() should be as in a Set.", hashCode, new HashSet<Object>(map .values()).hashCode());
assertEquals("hashCode() should be as in a Set.", hashCode, new HashSet<Object>(copy.values()).hashCode());
map.remove("identifiers");
final int newHashCode = citation.hashCode();
assertFalse(map.equals(copy));
assertFalse(hashCode == newHashCode);
assertEquals(newHashCode, new HashSet<Object>(map.values()).hashCode());
}