/*
 ----- BEGIN LICENSE BLOCK -----
 This Source Code Form is subject to the terms of the Mozilla Public License, v.2.0.
 If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
 ----- END LICENSE BLOCK -----
 */
package org.pharmgkb.common.comparator;

import org.junit.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


/**
 * JUnit test for {@link HaplotypeNameComparator}.
 *
 * @author Mark Woon
 */
public class HaplotypeNameComparatorTest {


  @Test
  public void testComparator() {

    assertEquals(0, HaplotypeNameComparator.getComparator().compare(null, null));
    assertEquals(-1, HaplotypeNameComparator.getComparator().compare(null, "*1"));
    assertEquals(1, HaplotypeNameComparator.getComparator().compare("*1", null));

    assertEquals(0, HaplotypeNameComparator.getComparator().compare("*1", "*1"));
    assertEquals(-1, HaplotypeNameComparator.getComparator().compare("*1", "*11"));
    assertEquals(-1, HaplotypeNameComparator.getComparator().compare("*2", "*11"));
    assertEquals(1, HaplotypeNameComparator.getComparator().compare("*13", "*3"));
    assertEquals(1, HaplotypeNameComparator.getComparator().compare("H3", "H2"));

    assertEquals(0, HaplotypeNameComparator.getComparator().compare("H2 EM", "H2 EM"));
    assertTrue(HaplotypeNameComparator.getComparator().compare("H2 EM", "H2 PM") < 0);
    assertTrue(HaplotypeNameComparator.getComparator().compare("H2 PM", "H2 EM") > 0);

    assertTrue(HaplotypeNameComparator.getComparator().compare("*1", "H2") < 0);
    assertTrue(HaplotypeNameComparator.getComparator().compare("*1", "TPMT") < 0);
    assertTrue(HaplotypeNameComparator.getComparator().compare("TPMT", "BRCA") > 0);
  }
}

@@ -299,16 +299,142 @@
 rator;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Iterator;%0Aimport java.util.List;%0Aimport java.util.Set;%0Aimport java.util.TreeSet;%0A
 import o
@@ -448,16 +448,16 @@
 t.Test;%0A
-
 %0Aimport 
@@ -1369,24 +1369,365 @@
 %22, %22H2%22));%0A%0A
+    assertEquals(-1, HaplotypeNameComparator.getComparator().compare(%22Any%22, %22*1%22));%0A    assertEquals(1, HaplotypeNameComparator.getComparator().compare(%22*1%22, %22Any%22));%0A    assertEquals(-1, HaplotypeNameComparator.getComparator().compare(%22*1%22, %22Other%22));%0A    assertEquals(1, HaplotypeNameComparator.getComparator().compare(%22Unknown%22, %22*1%22));%0A%0A
     assertEq
@@ -2133,32 +2133,32 @@
 , %22TPMT%22) %3C 0);%0A
-
     assertTrue(H
@@ -2230,10 +2230,515 @@
 0);%0A  %7D%0A
+  %0A  @Test%0A  public void testCollectionSorting() %7B%0A    List%3CString%3E input = new ArrayList%3C%3E();%0A    input.add(%22*3%22);%0A    input.add(%22Other%22);%0A    input.add(%22Any%22);%0A    input.add(%22*1%22);%0A    %0A    Set%3CString%3E orderedSet = new TreeSet%3C%3E(HaplotypeNameComparator.getComparator());%0A    orderedSet.addAll(input);%0A    %0A    Iterator%3CString%3E it = orderedSet.iterator();%0A    assertEquals(%22Any%22, it.next());%0A    assertEquals(%22*1%22, it.next());%0A    assertEquals(%22*3%22, it.next());%0A    assertEquals(%22Other%22, it.next());%0A  %7D%0A
 %7D%0A

Add more test cases for HaplotypeNameComparator