use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class AnnotationsTest method podamShouldHandleIntegerValues.
@Test
@Title("Podam should handle both native and wrapped integer values with @PodamIntValue annotation")
public void podamShouldHandleIntegerValues() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
IntegerValuePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(IntegerValuePojo.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
podamValidationSteps.theIntFieldShouldBeGreaterOrEqualToZero(pojo.getIntFieldWithMinValueOnly());
int maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED;
podamValidationSteps.theIntFieldShouldHaveValueNotGreaterThan(pojo.getIntFieldWithMaxValueOnly(), maxValue);
int minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE;
maxValue = PodamTestConstants.NUMBER_INT_MAX_VALUE;
podamValidationSteps.theIntFieldShouldHaveValueBetween(minValue, maxValue, pojo.getIntFieldWithMinAndMaxValue());
podamValidationSteps.thePojoMustBeOfTheType(pojo.getIntegerObjectFieldWithMinValueOnly(), Integer.class);
podamValidationSteps.theIntFieldShouldBeGreaterOrEqualToZero(pojo.getIntegerObjectFieldWithMinValueOnly());
podamValidationSteps.thePojoMustBeOfTheType(pojo.getIntegerObjectFieldWithMaxValueOnly(), Integer.class);
maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED;
podamValidationSteps.theIntFieldShouldHaveValueNotGreaterThan(pojo.getIntegerObjectFieldWithMaxValueOnly(), maxValue);
podamValidationSteps.thePojoMustBeOfTheType(pojo.getIntegerObjectFieldWithMinAndMaxValue(), Integer.class);
maxValue = PodamTestConstants.NUMBER_INT_MAX_VALUE;
podamValidationSteps.theIntFieldShouldHaveValueBetween(minValue, maxValue, pojo.getIntegerObjectFieldWithMinAndMaxValue());
int preciseValue = Integer.valueOf(PodamTestConstants.INTEGER_PRECISE_VALUE);
podamValidationSteps.theIntFieldShouldHaveThePreciseValueOf(pojo.getIntFieldWithPreciseValue(), preciseValue);
podamValidationSteps.thePojoMustBeOfTheType(pojo.getIntegerObjectFieldWithPreciseValue(), Integer.class);
podamValidationSteps.theIntFieldShouldHaveThePreciseValueOf(pojo.getIntegerObjectFieldWithPreciseValue(), preciseValue);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class AnnotationsTest method podamShouldHandleByteValuesWithThePodamByteValueAnnotation.
@Test
@Title("Podam should handle both native and wrapped byte values with @PodamByteValue annotation")
public void podamShouldHandleByteValuesWithThePodamByteValueAnnotation() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ByteValuePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ByteValuePojo.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
byte byteFieldWithMinValueOnly = pojo.getByteFieldWithMinValueOnly();
podamValidationSteps.theByteValueShouldBeGreaterOrEqualThan(byteFieldWithMinValueOnly, PodamTestConstants.NUMBER_INT_MIN_VALUE);
byte byteFieldWithMaxValueOnly = pojo.getByteFieldWithMaxValueOnly();
podamValidationSteps.theByteValueShouldBeLowerOrEqualThan(byteFieldWithMaxValueOnly, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
byte byteFieldWithMinAndMaxValue = pojo.getByteFieldWithMinAndMaxValue();
podamValidationSteps.theByteValueShouldBeBetween(byteFieldWithMinAndMaxValue, PodamTestConstants.NUMBER_INT_MIN_VALUE, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
Byte byteObjectFieldWithMinValueOnly = pojo.getByteObjectFieldWithMinValueOnly();
podamValidationSteps.theObjectShouldNotBeNull(byteObjectFieldWithMinValueOnly);
podamValidationSteps.theByteValueShouldBeGreaterOrEqualThan(byteObjectFieldWithMinValueOnly, PodamTestConstants.NUMBER_INT_MIN_VALUE);
Byte byteObjectFieldWithMaxValueOnly = pojo.getByteObjectFieldWithMaxValueOnly();
podamValidationSteps.theObjectShouldNotBeNull(byteFieldWithMaxValueOnly);
podamValidationSteps.theByteValueShouldBeLowerOrEqualThan(byteObjectFieldWithMaxValueOnly, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
Byte byteObjectFieldWithMinAndMaxValue = pojo.getByteObjectFieldWithMinAndMaxValue();
podamValidationSteps.theObjectShouldNotBeNull(byteObjectFieldWithMinAndMaxValue);
podamValidationSteps.theByteValueShouldBeBetween(byteObjectFieldWithMinAndMaxValue, PodamTestConstants.NUMBER_INT_MIN_VALUE, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
byte byteFieldWithPreciseValue = pojo.getByteFieldWithPreciseValue();
podamValidationSteps.theByteValueShouldHavePreciselyValueOf(byteFieldWithPreciseValue, Byte.valueOf(PodamTestConstants.BYTE_PRECISE_VALUE));
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class AnnotationsTest method podamShouldHandleConstructorsWithOneOrMoreSelfReferences.
@Test
@Title("Podam should handle POJOs with constructors that have one or more self references to the POJO class, " + "provided the required constructor is annotated with @PodamConstructor")
public void podamShouldHandleConstructorsWithOneOrMoreSelfReferences() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ConstructorWithSelfReferencesPojoAndDefaultConstructor pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ConstructorWithSelfReferencesPojoAndDefaultConstructor.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
constructorSelfReferenceValidationSteps.theFirstSelfReferenceForPojoWithDefaultConstructorShouldNotBeNull(pojo);
constructorSelfReferenceValidationSteps.theSecondSelfReferenceForPojoWithDefaultConstructorShouldNotBeNull(pojo);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class AnnotationsTest method podamShouldHandleCharValuesWithThePodamCharValueAnnotation.
@Test
@Title("Podam should handle both native and wrapped char values with @PodamCharValue annotation")
public void podamShouldHandleCharValuesWithThePodamCharValueAnnotation() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
CharValuePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(CharValuePojo.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
char charFieldWithMinValueOnly = pojo.getCharFieldWithMinValueOnly();
podamValidationSteps.theCharValueShouldBeGreaterOrEqualThan(charFieldWithMinValueOnly, (char) PodamTestConstants.NUMBER_INT_MIN_VALUE);
char charFieldWithMaxValueOnly = pojo.getCharFieldWithMaxValueOnly();
podamValidationSteps.theCharValueShouldBeLowerOrEqualThan(charFieldWithMaxValueOnly, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
char charFieldWithMinAndMaxValue = pojo.getCharFieldWithMinAndMaxValue();
podamValidationSteps.theCharValueShouldBeBetween(charFieldWithMinAndMaxValue, PodamTestConstants.NUMBER_INT_MIN_VALUE, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
Character charObjectFieldWithMinValueOnly = pojo.getCharObjectFieldWithMinValueOnly();
podamValidationSteps.theObjectShouldNotBeNull(charObjectFieldWithMinValueOnly);
podamValidationSteps.theCharValueShouldBeGreaterOrEqualThan(charObjectFieldWithMinValueOnly, (char) PodamTestConstants.NUMBER_INT_MIN_VALUE);
Character charObjectFieldWithMaxValueOnly = pojo.getCharObjectFieldWithMaxValueOnly();
podamValidationSteps.theCharValueShouldBeLowerOrEqualThan(charObjectFieldWithMaxValueOnly, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
Character charObjectFieldWithMinAndMaxValue = pojo.getCharObjectFieldWithMinAndMaxValue();
podamValidationSteps.theObjectShouldNotBeNull(charObjectFieldWithMinAndMaxValue);
podamValidationSteps.theCharValueShouldBeBetween(charObjectFieldWithMinAndMaxValue, PodamTestConstants.NUMBER_INT_MIN_VALUE, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
char charFieldWithPreciseValue = pojo.getCharFieldWithPreciseValue();
podamValidationSteps.theCharValueShouldBeExactly(charFieldWithPreciseValue, PodamTestConstants.CHAR_PRECISE_VALUE);
char charFieldWithBlankInPreciseValue = pojo.getCharFieldWithBlankInPreciseValue();
podamValidationSteps.theCharValueShouldBeExactly(charFieldWithBlankInPreciseValue, '