Search in sources :

Example 41 with PodamFactory

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);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 42 with PodamFactory

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));
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 43 with PodamFactory

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));
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 44 with PodamFactory

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);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 45 with PodamFactory

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());
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Aggregations

PodamFactory (uk.co.jemos.podam.api.PodamFactory)130 Test (org.junit.Test)127 Title (net.thucydides.core.annotations.Title)126 Validator (javax.validation.Validator)4 DataProviderStrategy (uk.co.jemos.podam.api.DataProviderStrategy)3 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 AbstractRandomDataProviderStrategy (uk.co.jemos.podam.api.AbstractRandomDataProviderStrategy)2 PodamFactoryImpl (uk.co.jemos.podam.api.PodamFactoryImpl)2 PojoWithMapsAndCollections (uk.co.jemos.podam.test.dto.PojoWithMapsAndCollections)2 SimplePojoToTestSetters (uk.co.jemos.podam.test.dto.SimplePojoToTestSetters)2 GenericCollectionsConstructorPojo (uk.co.jemos.podam.test.dto.issue123.GenericCollectionsConstructorPojo)2 BeanContextServicesSupport (java.beans.beancontext.BeanContextServicesSupport)1 InputStream (java.io.InputStream)1 BigDecimal (java.math.BigDecimal)1 URL (java.net.URL)1 Timestamp (java.sql.Timestamp)1 Currency (java.util.Currency)1 Date (java.util.Date)1 Observable (java.util.Observable)1