Java Code Examples for com.google.common.collect.Ordering.IncomparableValueException

The following are top voted examples for showing how to use com.google.common.collect.Ordering.IncomparableValueException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: guava-mock   File: OrderingTest.java   View source code 6 votes vote down vote up
public void testExplicit_two() {
  Comparator<Integer> c = Ordering.explicit(42, 5);
  assertEquals(0, c.compare(5, 5));
  assertTrue(c.compare(5, 42) > 0);
  assertTrue(c.compare(42, 5) < 0);
  try {
    c.compare(5, 666);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(666, expected.value);
  }
  new EqualsTester()
      .addEqualityGroup(c, Ordering.explicit(42, 5))
      .addEqualityGroup(Ordering.explicit(5, 42))
      .addEqualityGroup(Ordering.explicit(42))
      .testEquals();
  reserializeAndAssert(c);
}
 
Example 2
Project: googles-monorepo-demo   File: OrderingTest.java   View source code 6 votes vote down vote up
public void testExplicit_two() {
  Comparator<Integer> c = Ordering.explicit(42, 5);
  assertEquals(0, c.compare(5, 5));
  assertTrue(c.compare(5, 42) > 0);
  assertTrue(c.compare(42, 5) < 0);
  try {
    c.compare(5, 666);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(666, expected.value);
  }
  new EqualsTester()
      .addEqualityGroup(c, Ordering.explicit(42, 5))
      .addEqualityGroup(Ordering.explicit(5, 42))
      .addEqualityGroup(Ordering.explicit(42))
      .testEquals();
  reserializeAndAssert(c);
}
 
Example 3
Project: guava-libraries   File: OrderingTest.java   View source code 6 votes vote down vote up
public void testExplicit_two() {
  Comparator<Integer> c = Ordering.explicit(42, 5);
  assertEquals(0, c.compare(5, 5));
  assertTrue(c.compare(5, 42) > 0);
  assertTrue(c.compare(42, 5) < 0);
  try {
    c.compare(5, 666);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(666, expected.value);
  }
  new EqualsTester()
      .addEqualityGroup(c, Ordering.explicit(42, 5))
      .addEqualityGroup(Ordering.explicit(5, 42))
      .addEqualityGroup(Ordering.explicit(42))
      .testEquals();
  reserializeAndAssert(c);
}
 
Example 4
Project: guava-libraries   File: OrderingTest.java   View source code 6 votes vote down vote up
public void testExplicit_two() {
  Comparator<Integer> c = Ordering.explicit(42, 5);
  assertEquals(0, c.compare(5, 5));
  assertTrue(c.compare(5, 42) > 0);
  assertTrue(c.compare(42, 5) < 0);
  try {
    c.compare(5, 666);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(666, expected.value);
  }
  new EqualsTester()
      .addEqualityGroup(c, Ordering.explicit(42, 5))
      .addEqualityGroup(Ordering.explicit(5, 42))
      .addEqualityGroup(Ordering.explicit(42))
      .testEquals();
  reserializeAndAssert(c);
}
 
Example 5
Project: guava   File: OrderingTest.java   View source code 6 votes vote down vote up
public void testExplicit_two() {
  Comparator<Integer> c = Ordering.explicit(42, 5);
  assertEquals(0, c.compare(5, 5));
  assertTrue(c.compare(5, 42) > 0);
  assertTrue(c.compare(42, 5) < 0);
  try {
    c.compare(5, 666);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(666, expected.value);
  }
  new EqualsTester()
      .addEqualityGroup(c, Ordering.explicit(42, 5))
      .addEqualityGroup(Ordering.explicit(5, 42))
      .addEqualityGroup(Ordering.explicit(42))
      .testEquals();
  reserializeAndAssert(c);
}
 
Example 6
Project: guava   File: OrderingTest.java   View source code 6 votes vote down vote up
public void testExplicit_two() {
  Comparator<Integer> c = Ordering.explicit(42, 5);
  assertEquals(0, c.compare(5, 5));
  assertTrue(c.compare(5, 42) > 0);
  assertTrue(c.compare(42, 5) < 0);
  try {
    c.compare(5, 666);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(666, expected.value);
  }
  new EqualsTester()
      .addEqualityGroup(c, Ordering.explicit(42, 5))
      .addEqualityGroup(Ordering.explicit(5, 42))
      .addEqualityGroup(Ordering.explicit(42))
      .testEquals();
  reserializeAndAssert(c);
}
 
Example 7
Project: guava-mock   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_none() {
  Comparator<Integer> c
      = Ordering.explicit(Collections.<Integer>emptyList());
  try {
    c.compare(0, 0);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(0, expected.value);
  }
  reserializeAndAssert(c);
}
 
Example 8
Project: guava-mock   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_one() {
  Comparator<Integer> c = Ordering.explicit(0);
  assertEquals(0, c.compare(0, 0));
  try {
    c.compare(0, 1);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(1, expected.value);
  }
  reserializeAndAssert(c);
  assertEquals("Ordering.explicit([0])", c.toString());
}
 
Example 9
Project: googles-monorepo-demo   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_none() {
  Comparator<Integer> c
      = Ordering.explicit(Collections.<Integer>emptyList());
  try {
    c.compare(0, 0);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(0, expected.value);
  }
  reserializeAndAssert(c);
}
 
Example 10
Project: googles-monorepo-demo   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_one() {
  Comparator<Integer> c = Ordering.explicit(0);
  assertEquals(0, c.compare(0, 0));
  try {
    c.compare(0, 1);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(1, expected.value);
  }
  reserializeAndAssert(c);
  assertEquals("Ordering.explicit([0])", c.toString());
}
 
Example 11
Project: guava-libraries   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_none() {
  Comparator<Integer> c
      = Ordering.explicit(Collections.<Integer>emptyList());
  try {
    c.compare(0, 0);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(0, expected.value);
  }
  reserializeAndAssert(c);
}
 
Example 12
Project: guava-libraries   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_one() {
  Comparator<Integer> c = Ordering.explicit(0);
  assertEquals(0, c.compare(0, 0));
  try {
    c.compare(0, 1);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(1, expected.value);
  }
  reserializeAndAssert(c);
  assertEquals("Ordering.explicit([0])", c.toString());
}
 
Example 13
Project: guava-libraries   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_none() {
  Comparator<Integer> c
      = Ordering.explicit(Collections.<Integer>emptyList());
  try {
    c.compare(0, 0);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(0, expected.value);
  }
  reserializeAndAssert(c);
}
 
Example 14
Project: guava-libraries   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_one() {
  Comparator<Integer> c = Ordering.explicit(0);
  assertEquals(0, c.compare(0, 0));
  try {
    c.compare(0, 1);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(1, expected.value);
  }
  reserializeAndAssert(c);
  assertEquals("Ordering.explicit([0])", c.toString());
}
 
Example 15
Project: guava   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_none() {
  Comparator<Integer> c = Ordering.explicit(Collections.<Integer>emptyList());
  try {
    c.compare(0, 0);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(0, expected.value);
  }
  reserializeAndAssert(c);
}
 
Example 16
Project: guava   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_one() {
  Comparator<Integer> c = Ordering.explicit(0);
  assertEquals(0, c.compare(0, 0));
  try {
    c.compare(0, 1);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(1, expected.value);
  }
  reserializeAndAssert(c);
  assertEquals("Ordering.explicit([0])", c.toString());
}
 
Example 17
Project: guava   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_none() {
  Comparator<Integer> c = Ordering.explicit(Collections.<Integer>emptyList());
  try {
    c.compare(0, 0);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(0, expected.value);
  }
  reserializeAndAssert(c);
}
 
Example 18
Project: guava   File: OrderingTest.java   View source code 5 votes vote down vote up
public void testExplicit_one() {
  Comparator<Integer> c = Ordering.explicit(0);
  assertEquals(0, c.compare(0, 0));
  try {
    c.compare(0, 1);
    fail();
  } catch (IncomparableValueException expected) {
    assertEquals(1, expected.value);
  }
  reserializeAndAssert(c);
  assertEquals("Ordering.explicit([0])", c.toString());
}