49 lines
1.4 KiB
Java
49 lines
1.4 KiB
Java
package eu.dnetlib.dhp.schema.sx.scholix;
|
|
|
|
import static org.junit.jupiter.api.Assertions.*;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
public class ScholixCompareTest {
|
|
|
|
@Test
|
|
public void testNormalization() {
|
|
final String input = "Tĥïŝ ĩš â fůňķŷ Šťŕĭńġhttps://doi.org/< >10.11646/zootaxa.5099.1.3";
|
|
final String expected = "thisisafunkystringhttpsdoiorg1011646zootaxa509913";
|
|
final String normalized = ScholixComparator.normalizeString(input);
|
|
assertEquals(normalized, expected);
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
public void testScholixIdentifierComparison() {
|
|
final String id = "10.11646/zootaxa.5099.1.3";
|
|
final String schema = "DOI";
|
|
final String url ="http://dx.dOI.org/10.11646/Zootaxa.5099.1.3";
|
|
|
|
final ScholixIdentifier left = new ScholixIdentifier();
|
|
left.setIdentifier(id.toUpperCase());
|
|
left.setSchema(schema.toUpperCase());
|
|
left.setUrl(url.toUpperCase());
|
|
|
|
|
|
final ScholixIdentifier right = new ScholixIdentifier();
|
|
right.setIdentifier(id.toUpperCase());
|
|
right.setSchema(schema.toUpperCase());
|
|
right.setUrl(url.toLowerCase());
|
|
|
|
|
|
assertEquals(0,left.compareTo(right));
|
|
|
|
assertEquals(left, right);
|
|
assertEquals(left.hashCode(), right.hashCode());
|
|
|
|
|
|
left.setIdentifier(null);
|
|
|
|
assertEquals(-1, left.compareTo(right));
|
|
|
|
|
|
}
|
|
}
|