Esempio n. 1
0
  @Test
  public void testIntegerFilling() {
    IntegerValuePojo pojo = Filler.filling(IntegerValuePojo.class);
    Assert.assertNotNull("The pojo cannot be null!", pojo);
    int intFieldWithMinValueOnly = pojo.getIntFieldWithMinValueOnly();
    Assert.assertTrue(
        "The int field with only minValue should be >= 0", intFieldWithMinValueOnly >= 0);
    int intFieldWithMaxValueOnly = pojo.getIntFieldWithMaxValueOnly();
    Assert.assertTrue(
        "The int field with maximum value only should have a maximum value of 100",
        intFieldWithMaxValueOnly <= 100);
    int intObjectFieldWithMinAndMaxValue = pojo.getIntFieldWithMinAndMaxValue();
    Assert.assertTrue(
        "The int field with both min and max value should have a value comprised between",
        intObjectFieldWithMinAndMaxValue >= 0 && intObjectFieldWithMinAndMaxValue <= 1000);
    Integer integerObjectFieldWithMinValueOnly = pojo.getIntegerObjectFieldWithMinValueOnly();
    Assert.assertNotNull(
        "The integer field with minimum value only should not be null!",
        integerObjectFieldWithMinValueOnly);
    Assert.assertTrue(
        "The integer field with minimum value only should have a minimum value greater or equal to zero!",
        integerObjectFieldWithMinValueOnly.intValue() >= 0);
    Integer integerObjectFieldWithMaxValueOnly = pojo.getIntegerObjectFieldWithMaxValueOnly();
    Assert.assertNotNull(
        "The integer field with maximum value only should not be null!",
        integerObjectFieldWithMaxValueOnly);
    Assert.assertTrue(
        "The integer field with maximum value only should have a maximum value of 100",
        integerObjectFieldWithMaxValueOnly.intValue() <= 100);
    Integer integerObjectFieldWithMinAndMaxValue = pojo.getIntegerObjectFieldWithMinAndMaxValue();
    Assert.assertNotNull(
        "The integer field with minimum and maximum value should not be null!",
        integerObjectFieldWithMinAndMaxValue);
    Assert.assertTrue(
        "The integer field with minimum and maximum value should have value comprised between 0 and 1000",
        integerObjectFieldWithMinAndMaxValue.intValue() >= 0
            && integerObjectFieldWithMinAndMaxValue.intValue() <= 1000);

    int intFieldWithPreciseValue = pojo.getIntFieldWithPreciseValue();
    Assert.assertTrue(
        "The integer field with precise value must have a value of: "
            + FillDataTestConstants.INTEGER_PRECISE_VALUE,
        intFieldWithPreciseValue == Integer.valueOf(FillDataTestConstants.INTEGER_PRECISE_VALUE));

    Integer integerObjectFieldWithPreciseValue = pojo.getIntegerObjectFieldWithPreciseValue();
    Assert.assertNotNull(
        "The integer object field with precise value cannot be null!",
        integerObjectFieldWithPreciseValue);
    Assert.assertTrue(
        "The integer object field with precise value should have a value of "
            + FillDataTestConstants.INTEGER_PRECISE_VALUE,
        integerObjectFieldWithPreciseValue.intValue()
            == Integer.valueOf(FillDataTestConstants.INTEGER_PRECISE_VALUE));
  }
Esempio n. 2
0
  @Test
  public void testGetFilling() throws Exception {
    DoubleValuePojo pojo = Filler.filling(DoubleValuePojo.class);
    Assert.assertNotNull("The pojo cannot be null!", pojo);

    double doubleFieldWithMinValueOnly = pojo.getDoubleFieldWithMinValueOnly();
    Assert.assertTrue(
        "The double attribute with min value only must have a value greater than "
            + FillDataTestConstants.NUMBER_DOUBLE_MIN_VALUE,
        doubleFieldWithMinValueOnly >= FillDataTestConstants.NUMBER_DOUBLE_MIN_VALUE);

    double doubleFieldWithMaxValueOnly = pojo.getDoubleFieldWithMaxValueOnly();
    Assert.assertTrue(
        "The double attribute with max value only must have a value less or equal to "
            + FillDataTestConstants.NUMBER_DOUBLE_ONE_HUNDRED,
        doubleFieldWithMaxValueOnly <= FillDataTestConstants.NUMBER_DOUBLE_ONE_HUNDRED);

    double doubleFieldWithMinAndMaxValue = pojo.getDoubleFieldWithMinAndMaxValue();
    Assert.assertTrue(
        "The double attribute with min and mx value must have a value between "
            + FillDataTestConstants.NUMBER_DOUBLE_MIN_VALUE
            + " and "
            + FillDataTestConstants.NUMBER_DOUBLE_MAX_VALUE,
        doubleFieldWithMinAndMaxValue >= FillDataTestConstants.NUMBER_DOUBLE_MIN_VALUE
            && doubleFieldWithMinAndMaxValue <= FillDataTestConstants.NUMBER_DOUBLE_MAX_VALUE);

    double doubleFieldWithPreciseValue = pojo.getDoubleFieldWithPreciseValue();
    Assert.assertTrue(
        "The double field with precise value should have a value of: "
            + FillDataTestConstants.DOUBLE_PRECISE_VALUE,
        doubleFieldWithPreciseValue == Double.valueOf(FillDataTestConstants.DOUBLE_PRECISE_VALUE));

    Double doubleObjectFieldWithPreciseValue = pojo.getDoubleObjectFieldWithPreciseValue();
    Assert.assertNotNull(
        "The double object field with precise value cannot be null!",
        doubleObjectFieldWithPreciseValue);
    Assert.assertTrue(
        "The double object field with precise value should have a value of: "
            + FillDataTestConstants.DOUBLE_PRECISE_VALUE,
        doubleObjectFieldWithPreciseValue.doubleValue()
            == Double.valueOf(FillDataTestConstants.DOUBLE_PRECISE_VALUE).doubleValue());
  }
Esempio n. 3
0
 @Test(expected = PoJoFillException.class)
 public void testInteger_AnnotationWithNumberFormatError() {
   Filler.filling(IntegerValueWithErrorPojo.class);
 }
Esempio n. 4
0
 @Test
 public void testFillWith() throws Exception {
   Integer intValue = Filler.filling(int.class);
   want.number(intValue).notEqualTo(0);
 }
Esempio n. 5
0
 @Test(expected = PoJoFillException.class)
 public void testDoubleValueAnnotationWithError() {
   Filler.filling(DoubleValueWithErrorPojo.class);
 }