ConnectionSetupTimeComparator implements Comparator<NATTraversalTechnique>, Serializable { public static Comparator<NATTraversalTechnique> getInstance() { return INSTANCE; } private  ConnectionSetupTimeComparator(); @Override int compare(NATTraversalTechnique tech1, NATTraversalTechnique tech2); static Comparator<NATTraversalTechnique> getInstance();  }
@Test public void testSortedConnectionSetupTime() { this.expectedResult.add(new NATTraversalTechniqueMock("ConnectionReversal", 3, true)); this.expectedResult.add(new NATTraversalTechniqueMock("HolePunching", 5, true)); this.expectedResult.add(new NATTraversalTechniqueMock("Relaying", 0, false)); this.actualResult.add(new NATTraversalTechniqueMock("Relaying", 0, false)); this.actualResult.add(new NATTraversalTechniqueMock("HolePunching", 5, true)); this.actualResult.add(new NATTraversalTechniqueMock("ConnectionReversal", 3, true)); Collections.sort(this.actualResult, ConnectionSetupTimeComparator.getInstance()); assertEquals("The list has to be sorted by the ConnectionSetupTime correctly.", this.expectedResult, this.actualResult); }
@Test public void testSortedConnectionSetupTimeWithFallback() { this.expectedResult.add(new NATTraversalTechniqueMock("ConnectionReversal", 3, true)); this.expectedResult.add(new NATTraversalTechniqueMock("HolePunching", 5, true)); this.expectedResult.add(new NATTraversalTechniqueMock("Relaying", 0, false)); this.expectedResult.add(new NATTraversalTechniqueMock("Relaying2", 7, false)); this.actualResult.add(new NATTraversalTechniqueMock("Relaying2", 7, false)); this.actualResult.add(new NATTraversalTechniqueMock("HolePunching", 5, true)); this.actualResult.add(new NATTraversalTechniqueMock("Relaying", 0, false)); this.actualResult.add(new NATTraversalTechniqueMock("ConnectionReversal", 3, true)); Collections.sort(this.actualResult, ConnectionSetupTimeComparator.getInstance()); assertEquals("The list has to be sorted by the ConnectionSetupTime and fallback technique correctly.", this.expectedResult, this.actualResult); }