Search in sources :

Example 51 with PodamFactory

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

the class WalkThroughExampleUnitTest method testAddressSetup.

@Test
@Title("Podam should fill in the Address POJO correctly")
public void testAddressSetup() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    Address pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(Address.class, podamFactory);
    walkThroughSteps.theAddressPojoShouldBeCorrectlyFilled(pojo);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 52 with PodamFactory

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

the class AnnotationsTest method podamShouldHandleBooleanValuesWithThePodamBooleanValueAnnotation.

@Test
@Title("Podam should handle both native and wrapped boolean values with @PodamBooleanValue annotation")
public void podamShouldHandleBooleanValuesWithThePodamBooleanValueAnnotation() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    BooleanValuePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(BooleanValuePojo.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    boolean boolDefaultToTrue = pojo.isBoolDefaultToTrue();
    podamValidationSteps.theBooleanValueIsTrue(boolDefaultToTrue);
    boolean boolDefaultToFalse = pojo.isBoolDefaultToFalse();
    podamValidationSteps.theBooleanValueShouldBeFalse(boolDefaultToFalse);
    Boolean boolObjectDefaultToFalse = pojo.getBoolObjectDefaultToFalse();
    podamValidationSteps.theObjectShouldNotBeNull(boolObjectDefaultToFalse);
    podamValidationSteps.theBooleanValueShouldBeFalse(boolObjectDefaultToFalse);
    Boolean boolObjectDefaultToTrue = pojo.getBoolObjectDefaultToTrue();
    podamValidationSteps.theObjectShouldNotBeNull(boolObjectDefaultToTrue);
    podamValidationSteps.theBooleanValueIsTrue(boolObjectDefaultToTrue);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 53 with PodamFactory

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

the class AnnotationsTest method podamShouldHandlePojosWithAnnotatedFieldAndSetter.

@Test
@Title("Podam should handle POJOs with annotated field and setter")
public void podamShouldHandlePojosWithAnnotatedFieldAndSetter() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    AnnotatedFieldAndSetterPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(AnnotatedFieldAndSetterPojo.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    podamValidationSteps.theStringFieldCannotBeNullOrEmpty(pojo.getPostCode());
    podamValidationSteps.theStringValueShouldBeExactly(PodamTestConstants.POST_CODE, pojo.getPostCode());
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 54 with PodamFactory

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

the class AnnotationsTest method podamShouldHandleLongValues.

@Test
@Title("Podam should handle both native and wrapped long values with @PodamLongValue annotation")
public void podamShouldHandleLongValues() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    LongValuePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(LongValuePojo.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    podamValidationSteps.theLongFieldShouldBeGreaterOrEqualToZero(pojo.getLongFieldWithMinValueOnly());
    int maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED;
    podamValidationSteps.theLongFieldShouldHaveValueNotGreaterThan(pojo.getLongFieldWithMaxValueOnly(), maxValue);
    int minValue = PodamTestConstants.NUMBER_INT_MIN_VALUE;
    maxValue = PodamTestConstants.NUMBER_INT_MAX_VALUE;
    podamValidationSteps.theLongFieldShouldHaveValueBetween(minValue, maxValue, pojo.getLongFieldWithMinAndMaxValue());
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getLongObjectFieldWithMinValueOnly(), Long.class);
    podamValidationSteps.theLongFieldShouldBeGreaterOrEqualToZero(pojo.getLongObjectFieldWithMinValueOnly());
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getLongObjectFieldWithMaxValueOnly(), Long.class);
    maxValue = PodamTestConstants.NUMBER_INT_ONE_HUNDRED;
    podamValidationSteps.theLongFieldShouldHaveValueNotGreaterThan(pojo.getLongObjectFieldWithMinValueOnly(), maxValue);
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getLongObjectFieldWithMinAndMaxValue(), Long.class);
    maxValue = PodamTestConstants.NUMBER_INT_MAX_VALUE;
    podamValidationSteps.theLongFieldShouldHaveValueBetween(minValue, maxValue, pojo.getLongObjectFieldWithMinAndMaxValue());
    long preciseValue = Long.valueOf(PodamTestConstants.LONG_PRECISE_VALUE);
    podamValidationSteps.theLongFieldShouldHaveThePreciseValueOf(pojo.getLongFieldWithPreciseValue(), preciseValue);
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getLongObjectFieldWithPreciseValue(), Long.class);
    podamValidationSteps.theLongFieldShouldHaveThePreciseValueOf(pojo.getLongObjectFieldWithPreciseValue(), preciseValue);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 55 with PodamFactory

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

the class AnnotationsTest method podamShouldAssignExactValuesDefinedInPodamStrategyValueAnnotation.

@Test
@Title("Podam should assign exactly the values specified with the @PodamStrategyValue annotation")
public void podamShouldAssignExactValuesDefinedInPodamStrategyValueAnnotation() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    PodamStrategyPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(PodamStrategyPojo.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    String postCode = pojo.getPostCode();
    podamValidationSteps.theStringFieldCannotBeNullOrEmpty(postCode);
    podamValidationSteps.theStringValueShouldBeExactly(postCode, PodamTestConstants.POST_CODE);
    String postCode2 = pojo.getPostCode2();
    podamValidationSteps.theStringFieldCannotBeNullOrEmpty(postCode2);
    podamValidationSteps.theStringValueShouldBeExactly(postCode2, PodamTestConstants.POST_CODE);
    String postCode3 = pojo.getPostCode3();
    podamValidationSteps.theStringFieldCannotBeNullOrEmpty(postCode3);
    podamValidationSteps.theStringValueShouldBeExactly(postCode3, PodamTestConstants.POST_CODE);
    podamValidationSteps.theArrayOfTheGivenTypeShouldNotBeNullOrEmptyAndContainExactlyTheGivenNumberOfElements(pojo.getByteData(), ByteArrayStrategy.LENGTH, Byte.class);
    Calendar expectedBirthday = PodamTestUtils.getMyBirthday();
    Calendar myBirthday = pojo.getMyBirthday();
    podamValidationSteps.theTwoCalendarObjectsShouldHaveTheSameTime(expectedBirthday, myBirthday);
    List<Calendar> myBirthdays = pojo.getMyBirthdays();
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(myBirthdays, GregorianCalendar.class);
    for (Calendar birthday : myBirthdays) {
        podamValidationSteps.theTwoCalendarObjectsShouldHaveTheSameTime(expectedBirthday, birthday);
    }
    Calendar[] myBirthdaysArray = pojo.getMyBirthdaysArray();
    podamValidationSteps.theArrayOfTheGivenTypeShouldNotBeNullOrEmptyAndContainElementsOfTheRightType(myBirthdaysArray, GregorianCalendar.class);
    for (Calendar birthday : myBirthdaysArray) {
        podamValidationSteps.theTwoCalendarObjectsShouldHaveTheSameTime(expectedBirthday, birthday);
    }
    List<Object> objectList = pojo.getObjectList();
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(objectList, Object.class);
    Object[] myObjectArray = pojo.getMyObjectArray();
    podamValidationSteps.theArrayOfTheGivenTypeShouldNotBeNullOrEmptyAndContainElementsOfTheRightType(myObjectArray, Object.class);
    List<?> nonGenericObjectList = pojo.getNonGenericObjectList();
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(nonGenericObjectList, Object.class);
    Map<String, Calendar> myBirthdaysMap = pojo.getMyBirthdaysMap();
    podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(myBirthdaysMap, String.class, GregorianCalendar.class);
    Set<String> keySet = myBirthdaysMap.keySet();
    for (String key : keySet) {
        podamValidationSteps.theTwoCalendarObjectsShouldHaveTheSameTime(expectedBirthday, myBirthdaysMap.get(key));
    }
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) 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