Пример #1
0
 @Test
 public void testInvalidLabel() throws Exception {
   try {
     Type.LABEL.convert("not a label", null, currentRule);
     fail();
   } catch (Type.ConversionException e) {
     MoreAsserts.assertContainsWordsWithQuotes(e.getMessage(), "not a label");
   }
 }
Пример #2
0
 @Test
 public void testNonBoolean() throws Exception {
   try {
     Type.BOOLEAN.convert("unexpected", null);
     fail();
   } catch (Type.ConversionException e) {
     assertThat(e).hasMessage("expected value of type 'int', but got \"unexpected\" (string)");
   }
   // Integers other than [0, 1] should fail.
   try {
     Type.BOOLEAN.convert(2, null);
     fail();
   } catch (Type.ConversionException e) {
     assertEquals(e.getMessage(), "boolean is not one of [0, 1]");
   }
   try {
     Type.BOOLEAN.convert(-1, null);
     fail();
   } catch (Type.ConversionException e) {
     assertEquals(e.getMessage(), "boolean is not one of [0, 1]");
   }
 }