use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class SingletonsTest method podamShouldHandleSingletonsWithParametersInPublicStaticMethod.
@Test
@Title("Podam should handle Singletons with parameters in the static method")
public void podamShouldHandleSingletonsWithParametersInPublicStaticMethod() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
SingletonWithParametersInStaticFactoryPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(SingletonWithParametersInStaticFactoryPojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(pojo, SingletonWithParametersInStaticFactoryPojo.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo.getCreateDate(), GregorianCalendar.class);
podamValidationSteps.theStringFieldCannotBeNullOrEmpty(pojo.getFirstName());
List<OneDimensionalTestPojo> pojoList = pojo.getPojoList();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(pojoList, OneDimensionalTestPojo.class);
Map<String, OneDimensionalTestPojo> pojoMap = pojo.getPojoMap();
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(pojoMap, String.class, OneDimensionalTestPojo.class);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class ValidatedPojoTest method podamShouldFulfillMostOfTheJavaxValidationFramework.
@Test
@Title("Podam should be able to fulfill most of the javax Validation framework")
public void podamShouldFulfillMostOfTheJavaxValidationFramework() throws Exception {
AttributeStrategy<?> strategy = new EmailStrategy();
PodamFactory podamFactory = podamFactorySteps.givenAPodamFactoryWithCustomStrategy(Email.class, strategy);
ValidatedPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ValidatedPojo.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
podamValidationSteps.theObjectShouldNotBeNull(pojo.getBoolFalse());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getBoolTrue());
podamValidationSteps.theStringFieldCannotBeNullOrEmpty(pojo.getFilledString());
podamValidationSteps.theObjectShouldBeNull(pojo.getEmptyString());
podamValidationSteps.theStringFieldCannotBeNullOrEmpty(pojo.getNotEmptyString());
podamValidationSteps.theStringFieldCannotBeNullOrEmpty(pojo.getNotBlankString());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getDecimalDouble());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getDecimalFloat());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getDecimalString());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getLongNumber());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getIntNumber());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getBigIntNumber());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getShortNumber());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getByteNumber());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getIntString());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getFractionDecimal());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getFractionString());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getPastDate());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getFutureCalendar());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getSizedString());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getMaxCollection());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getMinCollection());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getDefaultCollection());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getDefaultMap());
podamValidationSteps.theObjectShouldNotBeNull(pojo.getEmail());
podamValidationSteps.theObjectShouldBeNull(pojo.getIdentifier());
Validator validator = podamFactorySteps.givenAJavaxValidator();
validatorSteps.thePojoShouldNotViolateAnyValidations(validator, pojo);
podamFactorySteps.removeCustomStrategy(podamFactory, Email.class);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class ValidatedPojoTest method whenMaxLengthIsNotSpecifiedInSizeAnnotationPodamShouldAssignASensibleDefault.
@Test
@Title("When the @Size annotation doesn't have a max length specified, Podam should assign a sensible value")
public void whenMaxLengthIsNotSpecifiedInSizeAnnotationPodamShouldAssignASensibleDefault() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ValidationPojoForStringWithSizeAndNoMax pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ValidationPojoForStringWithSizeAndNoMax.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
Validator validator = podamFactorySteps.givenAJavaxValidator();
validatorSteps.thePojoShouldNotViolateAnyValidations(validator, pojo);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class RandomDataProviderStrategyImplInitialisationUnitTest method podamShouldCorrectGenerateHashMapsWithLongAsKeyType.
@Test
@Title("Podam should correctly generate HashMaps with Long as key type")
public void podamShouldCorrectGenerateHashMapsWithLongAsKeyType() throws Exception {
DataProviderStrategy strategy = podamFactorySteps.givenACustomRandomDataProviderStrategy();
PodamFactory podamFactory = podamFactorySteps.givenAPodamFactoryWithCustomDataProviderStrategy(strategy);
Map<?, ?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(HashMap.class, podamFactory, Long.class, String.class);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
podamValidationSteps.theTwoObjectsShouldBeEqual(strategy.getNumberOfCollectionElements(String.class), pojo.size());
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class AbnormalPojosTest method podamShouldHandlePojosWithPrivateOnlyConstructors.
@Test
@Title("Podam should handle POJOs with private constructors only")
public void podamShouldHandlePojosWithPrivateOnlyConstructors() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
PrivateOnlyConstructorPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(PrivateOnlyConstructorPojo.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
podamValidationSteps.theStringFieldCannotBeNullOrEmpty(pojo.getFirstName());
podamValidationSteps.theIntFieldShouldNotBeZero(pojo.getIntField());
}
Aggregations