@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));
 }
Exemplo n.º 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"));
  }
Exemplo n.º 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));
  }
Exemplo n.º 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) {
    }
  }
Exemplo n.º 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) {
    }
  }
Exemplo n.º 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"));
 }
Exemplo n.º 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));
 }
Exemplo n.º 10
0
 // -----------------------------------------------------------------------
 public void test_toBooleanObject_boolean() {
   assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject(true));
   assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject(false));
 }
Exemplo n.º 11
0
 @Test(expected = IllegalArgumentException.class)
 public void test_toBooleanObject_String_String_String_String_noMatch() {
   BooleanUtils.toBooleanObject("X", "Y", "N", "U");
 }
Exemplo n.º 12
0
 @Test(expected = IllegalArgumentException.class)
 public void test_toBooleanObject_String_String_String_String_nullValue() {
   BooleanUtils.toBooleanObject((String) null, "Y", "N", "U");
 }
Exemplo n.º 13
0
 @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));
 }
Exemplo n.º 14
0
 @Test(expected = IllegalArgumentException.class)
 public void test_toBooleanObject_int_int_int_noMatch() {
   BooleanUtils.toBooleanObject(9, 6, 7, 8);
 }
Exemplo n.º 15
0
 // -----------------------------------------------------------------------
 @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));
 }