use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class AnnotationsTest method thePodamCollectionAnnotationShouldWorkOnAllCollections.
@Test
@Title("The @PodamCollection annotation should allow to set sizes on all collections and arrays")
public void thePodamCollectionAnnotationShouldWorkOnAllCollections() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
CollectionAnnotationPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(CollectionAnnotationPojo.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
List<String> strList = pojo.getStrList();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(strList, String.class, PodamTestConstants.ANNOTATION_COLLECTION_NBR_ELEMENTS);
String[] strArray = pojo.getStrArray();
podamValidationSteps.theArrayOfTheGivenTypeShouldNotBeNullOrEmptyAndContainElementsOfTheRightType(strArray, String.class);
podamValidationSteps.theArrayShouldHaveExactlyTheExpectedNumberOfElements(strArray, PodamTestConstants.ANNOTATION_COLLECTION_NBR_ELEMENTS);
Map<String, String> stringMap = pojo.getStringMap();
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(stringMap, String.class, String.class, PodamTestConstants.ANNOTATION_COLLECTION_NBR_ELEMENTS);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class AnnotationsTest method podamShouldHandleDoubleValuesWithThePodamDoubleValueAnnotation.
@Test
@Title("Podam should handle both native and wrapped double values with @PodamDoubleValue annotation")
public void podamShouldHandleDoubleValuesWithThePodamDoubleValueAnnotation() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
DoubleValuePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(DoubleValuePojo.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
double doubleFieldWithMinValueOnly = pojo.getDoubleFieldWithMinValueOnly();
podamValidationSteps.theDoubleValueShouldBeGreaterOrEqualThan(doubleFieldWithMinValueOnly, PodamTestConstants.NUMBER_DOUBLE_MIN_VALUE);
double doubleFieldWithMaxValueOnly = pojo.getDoubleFieldWithMaxValueOnly();
podamValidationSteps.theDoubleValueShouldBeLowerOrEqualThan(doubleFieldWithMaxValueOnly, PodamTestConstants.NUMBER_DOUBLE_ONE_HUNDRED);
double doubleFieldWithMinAndMaxValue = pojo.getDoubleFieldWithMinAndMaxValue();
podamValidationSteps.theDoubleValueShouldBeBetween(doubleFieldWithMinAndMaxValue, PodamTestConstants.NUMBER_DOUBLE_MIN_VALUE, PodamTestConstants.NUMBER_DOUBLE_MAX_VALUE);
double doubleFieldWithPreciseValue = pojo.getDoubleFieldWithPreciseValue();
podamValidationSteps.theDoubleValueShouldBeExactly(doubleFieldWithPreciseValue, Double.valueOf(PodamTestConstants.DOUBLE_PRECISE_VALUE));
Double doubleObjectFieldWithPreciseValue = pojo.getDoubleObjectFieldWithPreciseValue();
podamValidationSteps.theObjectShouldNotBeNull(doubleObjectFieldWithPreciseValue);
Assert.assertTrue("The double object field with precise value should have a value of: " + PodamTestConstants.DOUBLE_PRECISE_VALUE, doubleObjectFieldWithPreciseValue.doubleValue() == Double.valueOf(PodamTestConstants.DOUBLE_PRECISE_VALUE).doubleValue());
podamValidationSteps.theDoubleValueShouldBeExactly(doubleObjectFieldWithPreciseValue, Double.valueOf(PodamTestConstants.DOUBLE_PRECISE_VALUE));
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class AnnotationsTest method podamShouldHandleShortValuesWithThePodamShortValueAnnotation.
@Test
@Title("Podam should handle both native and wrapped short values with @PodamShortValue annotation")
public void podamShouldHandleShortValuesWithThePodamShortValueAnnotation() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ShortValuePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ShortValuePojo.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
short shortFieldWithMinValueOnly = pojo.getShortFieldWithMinValueOnly();
podamValidationSteps.theShortValueShouldBeGreaterOrEqualThan(shortFieldWithMinValueOnly, PodamTestConstants.NUMBER_INT_MIN_VALUE);
short shortFieldWithMaxValueOnly = pojo.getShortFieldWithMaxValueOnly();
podamValidationSteps.theShortValueShouldBeLowerOrEqualThan(shortFieldWithMaxValueOnly, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
short shortFieldWithMinAndMaxValue = pojo.getShortFieldWithMinAndMaxValue();
podamValidationSteps.theShortValueShouldBeBetween(shortFieldWithMinAndMaxValue, PodamTestConstants.NUMBER_INT_MIN_VALUE, PodamTestConstants.NUMBER_INT_MAX_VALUE);
Short shortObjectFieldWithMinValueOnly = pojo.getShortObjectFieldWithMinValueOnly();
podamValidationSteps.theObjectShouldNotBeNull(shortFieldWithMinValueOnly);
podamValidationSteps.theShortValueShouldBeGreaterOrEqualThan(shortObjectFieldWithMinValueOnly, PodamTestConstants.NUMBER_INT_MIN_VALUE);
Short shortObjectFieldWithMaxValueOnly = pojo.getShortObjectFieldWithMaxValueOnly();
podamValidationSteps.theObjectShouldNotBeNull(shortFieldWithMaxValueOnly);
podamValidationSteps.theShortValueShouldBeLowerOrEqualThan(shortObjectFieldWithMaxValueOnly, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
Short shortObjectFieldWithMinAndMaxValue = pojo.getShortObjectFieldWithMinAndMaxValue();
podamValidationSteps.theObjectShouldNotBeNull(shortObjectFieldWithMinAndMaxValue);
podamValidationSteps.theShortValueShouldBeBetween(shortObjectFieldWithMinAndMaxValue, PodamTestConstants.NUMBER_INT_MIN_VALUE, PodamTestConstants.NUMBER_INT_ONE_HUNDRED);
short shortFieldWithPreciseValue = pojo.getShortFieldWithPreciseValue();
podamValidationSteps.theShortPreciseValueShouldBe(shortFieldWithPreciseValue, Short.valueOf(PodamTestConstants.SHORT_PRECISE_VALUE));
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class PodamFactoryBasicTypesTest method podamShouldFillRecursivePojos.
@Test
@Title("Podam should fill recursive POJOs correctly, including all their fields")
public void podamShouldFillRecursivePojos() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
RecursivePojo recursivePojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(RecursivePojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(recursivePojo, RecursivePojo.class);
recursivePojoValidationSteps.allPojosInTheRecursiveStrategyShouldBeValid(recursivePojo);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class PodamFactoryBasicTypesTest method podamShouldGenerateBasicTypes.
@Test
@Title("Podam should fill in a POJO with basic jvm types")
public void podamShouldGenerateBasicTypes() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
OneDimensionalTestPojo oneDimensionalTestPojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(OneDimensionalTestPojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(oneDimensionalTestPojo, OneDimensionalTestPojo.class);
podamValidationSteps.thePojoShouldContainSomeData(oneDimensionalTestPojo);
oneDimentionalPojoValidationSteps.validateDimensionalTestPojo(oneDimensionalTestPojo, podamFactory.getStrategy());
}
Aggregations