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);
}
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);
}
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());
}
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);
}
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));
}
}
Aggregations