Search in sources :

Example 56 with PodamFactory

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

Example 57 with PodamFactory

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

Example 58 with PodamFactory

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

Example 59 with PodamFactory

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

Example 60 with PodamFactory

use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.

the class AnnotationsTest method podamShouldHandleImmutablePojosAnnotatedWithPodamConstructor.

@Test
@Title("Podam should handle immutable POJOs annotated with @PodamConstructor")
public void podamShouldHandleImmutablePojosAnnotatedWithPodamConstructor() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    ImmutableNoHierarchicalAnnotatedPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ImmutableNoHierarchicalAnnotatedPojo.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    podamValidationSteps.theIntFieldShouldNotBeZero(pojo.getIntField());
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getDateCreated(), GregorianCalendar.class);
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getDateCreated().getTime(), Date.class);
    podamValidationSteps.theArrayOfTheGivenTypeShouldNotBeNullOrEmptyAndContainElementsOfTheRightType(pojo.getLongArray(), Long.class);
    podamValidationSteps.theLongValueShouldNotBeZero(pojo.getLongArray()[0]);
}
Also used : ImmutableNoHierarchicalAnnotatedPojo(uk.co.jemos.podam.test.dto.ImmutableNoHierarchicalAnnotatedPojo) 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