@Test
 public void test_toBooleanObject_Integer() {
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(1)));
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(-1)));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(0)));
   assertEquals(null, BooleanUtils.toBooleanObject((Integer) null));
 }
Example #2
0
 // -----------------------------------------------------------------------
 public void test_toBooleanObject_int_int_int() {
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(6, 6, 7, 8));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(7, 6, 7, 8));
   assertEquals(null, BooleanUtils.toBooleanObject(8, 6, 7, 8));
   try {
     BooleanUtils.toBooleanObject(9, 6, 7, 8);
     fail();
   } catch (IllegalArgumentException ex) {
   }
 }
  @Test
  public void test_toBooleanObject_String_String_String_String() {
    assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((String) null, null, "N", "U"));
    assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((String) null, "Y", null, "U"));
    assertSame(null, BooleanUtils.toBooleanObject((String) null, "Y", "N", null));

    assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y", "Y", "N", "U"));
    assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N", "Y", "N", "U"));
    assertEquals(null, BooleanUtils.toBooleanObject("U", "Y", "N", "U"));
  }
Example #4
0
  public void test_toBooleanObject_String_String_String_String() {
    assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((String) null, null, "N", "U"));
    assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((String) null, "Y", null, "U"));
    assertSame(null, BooleanUtils.toBooleanObject((String) null, "Y", "N", null));
    try {
      BooleanUtils.toBooleanObject((String) null, "Y", "N", "U");
      fail();
    } catch (IllegalArgumentException ex) {
    }

    assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y", "Y", "N", "U"));
    assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N", "Y", "N", "U"));
    assertEquals(null, BooleanUtils.toBooleanObject("U", "Y", "N", "U"));
    try {
      BooleanUtils.toBooleanObject(null, "Y", "N", "U");
      fail();
    } catch (IllegalArgumentException ex) {
    }
    try {
      BooleanUtils.toBooleanObject("X", "Y", "N", "U");
      fail();
    } catch (IllegalArgumentException ex) {
    }
  }
  @Test
  public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
    Integer six = Integer.valueOf(6);
    Integer seven = Integer.valueOf(7);
    Integer eight = Integer.valueOf(8);

    assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven, eight));
    assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null, eight));
    assertSame(null, BooleanUtils.toBooleanObject((Integer) null, six, seven, null));

    assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(Integer.valueOf(6), six, seven, eight));
    assertEquals(
        Boolean.FALSE, BooleanUtils.toBooleanObject(Integer.valueOf(7), six, seven, eight));
    assertEquals(null, BooleanUtils.toBooleanObject(Integer.valueOf(8), six, seven, eight));
  }
Example #6
0
  public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
    Integer six = new Integer(6);
    Integer seven = new Integer(7);
    Integer eight = new Integer(8);

    assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven, eight));
    assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null, eight));
    assertSame(null, BooleanUtils.toBooleanObject((Integer) null, six, seven, null));
    try {
      BooleanUtils.toBooleanObject(null, six, seven, eight);
      fail();
    } catch (IllegalArgumentException ex) {
    }

    assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(6), six, seven, eight));
    assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(new Integer(7), six, seven, eight));
    assertEquals(null, BooleanUtils.toBooleanObject(new Integer(8), six, seven, eight));
    try {
      BooleanUtils.toBooleanObject(new Integer(9), six, seven, eight);
      fail();
    } catch (IllegalArgumentException ex) {
    }
  }
Example #7
0
  public void test_toBoolean_String_String_String() {
    assertEquals(true, BooleanUtils.toBoolean((String) null, null, "N"));
    assertEquals(false, BooleanUtils.toBoolean((String) null, "Y", null));
    try {
      BooleanUtils.toBooleanObject((String) null, "Y", "N", "U");
      fail();
    } catch (IllegalArgumentException ex) {
    }

    assertEquals(true, BooleanUtils.toBoolean("Y", "Y", "N"));
    assertEquals(false, BooleanUtils.toBoolean("N", "Y", "N"));
    try {
      BooleanUtils.toBoolean(null, "Y", "N");
      fail();
    } catch (IllegalArgumentException ex) {
    }
    try {
      BooleanUtils.toBoolean("X", "Y", "N");
      fail();
    } catch (IllegalArgumentException ex) {
    }
  }
Example #8
0
 // -----------------------------------------------------------------------
 // -----------------------------------------------------------------------
 public void test_toBooleanObject_String() {
   assertEquals(null, BooleanUtils.toBooleanObject((String) null));
   assertEquals(null, BooleanUtils.toBooleanObject(""));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("false"));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("no"));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("off"));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("FALSE"));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("NO"));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("OFF"));
   assertEquals(null, BooleanUtils.toBooleanObject("oof"));
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("true"));
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("yes"));
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("on"));
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TRUE"));
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("ON"));
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("YES"));
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("TruE"));
 }
Example #9
0
 public void test_toBooleanObject_int() {
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(1));
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(-1));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(0));
 }
Example #10
0
 // -----------------------------------------------------------------------
 public void test_toBooleanObject_boolean() {
   assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(true));
   assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject(false));
 }
 @Test(expected = IllegalArgumentException.class)
 public void test_toBooleanObject_String_String_String_String_noMatch() {
   BooleanUtils.toBooleanObject("X", "Y", "N", "U");
 }
 @Test(expected = IllegalArgumentException.class)
 public void test_toBooleanObject_String_String_String_String_nullValue() {
   BooleanUtils.toBooleanObject((String) null, "Y", "N", "U");
 }
 @Test(expected = IllegalArgumentException.class)
 public void test_toBooleanObject_Integer_Integer_Integer_Integer_noMatch() {
   BooleanUtils.toBooleanObject(
       Integer.valueOf(9), Integer.valueOf(6), Integer.valueOf(7), Integer.valueOf(8));
 }
 @Test(expected = IllegalArgumentException.class)
 public void test_toBooleanObject_int_int_int_noMatch() {
   BooleanUtils.toBooleanObject(9, 6, 7, 8);
 }
 // -----------------------------------------------------------------------
 @Test
 public void test_toBooleanObject_int_int_int() {
   assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(6, 6, 7, 8));
   assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(7, 6, 7, 8));
   assertEquals(null, BooleanUtils.toBooleanObject(8, 6, 7, 8));
 }