/*
 *BridgeDb,
 *An abstraction layer for identifier mapping services, both local and online.
 *Copyright (c) 2013 Egon Willighagen <egonw@users.sf.net>
 *
 *Licensed under the Apache License, Version 2.0 (the "License");
 *you may not use this file except in compliance with the License.
 *You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 *Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *See the License for the specific language governing permissions and limitations under the License.
 */
package org.bridgedb;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

public class XrefTest {

    //Oct 29, 2013 Name changed to match that used elsewhere
	private final DataSource EN = DataSource.register("En", "Ensembl").asDataSource();
	private final DataSource UNIPROT = DataSource.register("S", "Uniprot-TrEMBL").
		urnBase("urn:miriam:uniprot:").asDataSource();

	@Test
	public void testConstructor() {
		Xref xref = new Xref("ENSG000001", EN);
		assertNotNull(xref);
		assertEquals("ENSG000001", xref.getId());
		assertNotNull(xref.getDataSource());
		assertEquals("En", xref.getDataSource().getSystemCode());
	}

	@Test
	public void testEquals_Null() {
		Xref xref = new Xref("ENSG000001", EN);
		assertNotEquals(null, xref);
	}

	@Test
	public void testEquals_NonXref() {
		Xref xref = new Xref("ENSG000001", EN);
		assertNotEquals("ENSG000001", xref);
	}

	@Test
	public void testEquals_DiffId() {
		Xref xref = new Xref("ENSG000001", EN);
		Xref xref2 = new Xref("ENSG000002", EN);
		assertNotEquals(xref, xref2);
		assertNotEquals(xref2, xref); // and symmetric
	}

	@Test
	public void testEquals() {
		Xref xref = new Xref("ENSG000001", EN);
		Xref xref2 = new Xref("ENSG000001", EN);
		assertEquals(xref, xref2);
		assertEquals(xref2, xref); // and symmetric
	}

	@Test
	public void testCompareTo() {
		Xref xref = new Xref("ENSG000001", EN);
		Xref xref2 = new Xref("ENSG000001", EN);
		assertEquals(0, xref.compareTo(xref2));
		assertEquals(0, xref2.compareTo(xref)); // and symmetric
	}

	@Test
	public void testCompareTo_Diff() {
		Xref xref = new Xref("ENSG000001", EN);
		Xref xref2 = new Xref("ENSG000002", EN);
		assertNotSame(0, xref.compareTo(xref2));
		assertNotSame(0, xref2.compareTo(xref)); // and symmetric
	}

	@Test
	public void testURNRoundtripping() {
		Xref xref = new Xref("P12345", UNIPROT);
		String urn = xref.getURN();
		assertNotNull(urn);
		assertNotSame(0, urn.length());
		Xref xref2 = Xref.fromUrn(urn);
		assertEquals(xref, xref2);
		assertEquals(xref2, xref); // and symmetric
	}
}

@@ -1992,32 +1992,164 @@
 / and symmetric%0A
+%09%09Xref xref3 = new Xref(%22ENSG000001%22, EN, true);%0A%09%09Xref xref4 = new Xref(%22ENSG000001%22, EN, false);%0A%09%09assertNotEquals(xref3, xref4);%0A
 %09%7D%0A%0A%09@Test%0A%09publ
@@ -2177,32 +2177,33 @@
 () %7B%0A%09%09Xref xref
+1
  = new Xref(%22ENS
@@ -2274,32 +2274,33 @@
 rtEquals(0, xref
+1
 .compareTo(xref2
@@ -2333,33 +2333,267 @@
 2.compareTo(xref
-)
+1)); // and symmetric%0A%09%09Xref xref3 = new Xref(%22ENSG000001%22, EN, true);%0A%09%09Xref xref4 = new Xref(%22ENSG000001%22, EN, false);%0A%09%09assertNotEquals(xref3.isPrimary(), xref4.isPrimary());%0A%09%09assertEquals(xref3, xref4);%0A%09%09assertEquals(xref4, xref3
 ); // and symmet

Update XrefTest.java