@SuppressWarnings("UnaryPlus") public void testMappingToNodes(){
  String n1="node #1";
  String n2="node #2";
  String n3="node #3";
  String n4="node #4";
  List<String> nodes=Arrays.asList(n1,n2,n3,n4);
  GridClientConsistentHash<String> hash=new GridClientConsistentHash<>();
  for (  String node : nodes)   hash.addNode(node,5);
  Map<Object,String> data=new LinkedHashMap<>();
  data.put("",n1);
  data.put("asdf",n3);
  data.put("224ea4cd-f449-4dcb-869a-5317c63bd619",n2);
  data.put("fdc9ec54-ff53-4fdb-8239-5a3ac1fb31bd",n4);
  data.put("0f9c9b94-02ae-45a6-9d5c-a066dbdf2636",n1);
  data.put("d8f1f916-4357-4cfe-a7df-49d4721690bf",n3);
  data.put("c77ffeae-78a1-4ee6-a0fd-8d197a794412",n4);
  data.put("35de9f21-3c9b-4f4a-a7d5-3e2c6cb01564",n4);
  data.put("d67eb652-4e76-47fb-ad4e-cd902d9b868a",n4);
  data.put(0,n1);
  data.put(1,n4);
  data.put(12,n3);
  data.put(123,n3);
  data.put(1234,n3);
  data.put(12345,n4);
  data.put(123456,n3);
  data.put(1234567,n4);
  data.put(12345678,n4);
  data.put(123456789,n4);
  data.put(1234567890,n3);
  data.put(1234567890L,n3);
  data.put(12345678901L,n4);
  data.put(123456789012L,n2);
  data.put(1234567890123L,n4);
  data.put(12345678901234L,n1);
  data.put(123456789012345L,n1);
  data.put(1234567890123456L,n3);
  data.put(-23456789012345L,n2);
  data.put(-2345678901234L,n1);
  data.put(-234567890123L,n4);
  data.put(-23456789012L,n3);
  data.put(-2345678901L,n3);
  data.put(-234567890L,n1);
  data.put(-234567890,n4);
  data.put(-23456789,n4);
  data.put(-2345678,n4);
  data.put(-234567,n4);
  data.put(-23456,n4);
  data.put(-2345,n1);
  data.put(-234,n4);
  data.put(-23,n3);
  data.put(-2,n4);
  data.put(0x80000000,n2);
  data.put(0x7fffffff,n4);
  data.put(0x8000000000000000L,n2);
  data.put(0x7fffffffffffffffL,n2);
  data.put(+1.1,n1);
  data.put(-10.01,n3);
  data.put(+100.001,n3);
  data.put(-1000.0001,n4);
  data.put(+1.7976931348623157E+308,n4);
  data.put(-1.7976931348623157E+308,n4);
  data.put(+4.9E-324,n4);
  data.put(-4.9E-324,n3);
  for (  Map.Entry<Object,String> entry : data.entrySet())   assertEquals("Validate key '" + entry.getKey() + "'.",entry.getValue(),hash.node(entry.getKey()));
  for (  Map.Entry<Object,String> entry : data.entrySet())   assertEquals("Validate key '" + entry.getKey() + "'.",entry.getValue(),hash.node(entry.getKey(),nodes));
  nodes=new ArrayList<>(nodes);
  Collections.reverse(nodes);
  hash=new GridClientConsistentHash<>();
  for (  String node : nodes)   hash.addNode(node,5);
  for (  Map.Entry<Object,String> entry : data.entrySet())   assertEquals("Validate key '" + entry.getKey() + "'.",entry.getValue(),hash.node(entry.getKey()));
  for (  Map.Entry<Object,String> entry : data.entrySet())   assertEquals("Validate key '" + entry.getKey() + "'.",entry.getValue(),hash.node(entry.getKey(),nodes));
}

@ SuppressWarnings ( "UnaryPlus" ) public void testMappingToNodes ( ) { String n1 = "node #1" ; String n2 = "node #2" ; String n3 = "node #3" ; String n4 = "node #4" ; List < String > nodes = Arrays . asList ( n1 , n2 , n3 , n4 ) ; GridClientConsistentHash < String > hash = new GridClientConsistentHash < > ( ) ; for ( String node : nodes ) hash . addNode ( node , 5 ) ; Map < Object , String > data = new LinkedHashMap < > ( ) ; data . put ( "" , n1 ) ; data . put ( "asdf" , n3 ) ; data . put ( "224ea4cd-f449-4dcb-869a-5317c63bd619" , n2 ) ; data . put ( "fdc9ec54-ff53-4fdb-8239-5a3ac1fb31bd" , n4 ) ; data . put ( "0f9c9b94-02ae-45a6-9d5c-a066dbdf2636" , n1 ) ; data . put ( "d8f1f916-4357-4cfe-a7df-49d4721690bf" , n3 ) ; data . put ( "c77ffeae-78a1-4ee6-a0fd-8d197a794412" , n4 ) ; data . put ( "35de9f21-3c9b-4f4a-a7d5-3e2c6cb01564" , n4 ) ; data . put ( "d67eb652-4e76-47fb-ad4e-cd902d9b868a" , n4 ) ; data . put ( 0 , n1 ) ; data . put ( 1 , n4 ) ; data . put ( 12 , n3 ) ; data . put ( 123 , n3 ) ; data . put ( 1234 , n3 ) ; data . put ( 12345 , n4 ) ; data . put ( 123456 , n3 ) ; data . put ( 1234567 , n4 ) ; data . put ( 12345678 , n4 ) ; data . put ( 123456789 , n4 ) ; data . put ( 1234567890 , n3 ) ; data . put ( 1234567890L , n3 ) ; data . put ( 12345678901L , n4 ) ; data . put ( 123456789012L , n2 ) ; data . put ( 1234567890123L , n4 ) ; data . put ( 12345678901234L , n1 ) ; data . put ( 123456789012345L , n1 ) ; data . put ( 1234567890123456L , n3 ) ; data . put ( - 23456789012345L , n2 ) ; data . put ( - 2345678901234L , n1 ) ; data . put ( - 234567890123L , n4 ) ; data . put ( - 23456789012L , n3 ) ; data . put ( - 2345678901L , n3 ) ; data . put ( - 234567890L , n1 ) ; data . put ( - 234567890 , n4 ) ; data . put ( - 23456789 , n4 ) ; data . put ( - 2345678 , n4 ) ; data . put ( - 234567 , n4 ) ; data . put ( - 23456 , n4 ) ; data . put ( - 2345 , n1 ) ; data . put ( - 234 , n4 ) ; data . put ( - 23 , n3 ) ; data . put ( - 2 , n4 ) ; data . put ( 0x80000000 , n2 ) ; data . put ( 0x7fffffff , n4 ) ; data . put ( 0x8000000000000000L , n2 ) ; data . put ( 0x7fffffffffffffffL , n2 ) ; data . put ( + 1.1 , n1 ) ; data . put ( - 10.01 , n3 ) ; data . put ( + 100.001 , n3 ) ; data . put ( - 1000.0001 , n4 ) ; data . put ( + 1.7976931348623157E+308 , n4 ) ; data . put ( - 1.7976931348623157E+308 , n4 ) ; data . put ( + 4.9E-324 , n4 ) ; data . put ( - 4.9E-324 , n3 ) ; for ( Map . Entry < Object , String > entry : data . entrySet ( ) ) assertEquals ( "Validate key '" + entry . getKey ( ) + "'." , entry . getValue ( ) , hash . node ( entry . getKey ( ) ) ) ; for ( Map . Entry < Object , String > entry : data . entrySet ( ) ) assertEquals ( "Validate key '" + entry . getKey ( ) + "'." , entry . getValue ( ) , hash . node ( entry . getKey ( ) , nodes ) ) ; nodes = new ArrayList < > ( nodes ) ; Collections . reverse ( nodes ) ; hash = new GridClientConsistentHash < > ( ) ; for ( String node : nodes ) hash . addNode ( node , 5 ) ; for ( Map . Entry < Object , String > entry : data . entrySet ( ) ) assertEquals ( "Validate key '" + entry . getKey ( ) + "'." , entry . getValue ( ) , hash . node ( entry . getKey ( ) ) ) ; for ( Map . Entry < Object , String > entry : data . entrySet ( ) ) assertEquals ( "Validate key '" + entry . getKey ( ) + "'." , entry . getValue ( ) , hash . node ( entry . getKey ( ) , nodes ) ) ; }
test mapping to nodes .
