use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class ExternalFactoryUnitTest method podamShouldNotcreateInstancesOfNonInstantiableClasses.
@Test
@Title("Podam should not create instances of non-instantiable classes")
public void podamShouldNotcreateInstancesOfNonInstantiableClasses() throws Exception {
TestExternalFactory externalFactory = (TestExternalFactory) podamFactorySteps.givenAnExternalFactory();
PodamFactory podamFactory = podamFactorySteps.givenAdPodamFactoryWithExternalFactory(externalFactory);
podamValidationSteps.theTwoObjectsShouldBeEqual(podamFactory.getExternalFactory(), externalFactory);
NonInstantiatableClass pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(NonInstantiatableClass.class, podamFactory);
podamValidationSteps.theObjectShouldBeNull(pojo);
podamValidationSteps.theTwoObjectsShouldBeEqual(1, externalFactory.getFailures().size());
podamValidationSteps.theTwoObjectsShouldBeEqual(NonInstantiatableClass.class, externalFactory.getFailures().get(0));
podamValidationSteps.theTwoObjectsShouldBeEqual(0, externalFactory.getFullDataCalls().size());
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class CollectionsTest method podamShouldHandleImmutablePojosWithNonGenericCollections.
@Test
@Title("Podam should handle immutable Pojos with non generic collections")
public void podamShouldHandleImmutablePojosWithNonGenericCollections() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ImmutableWithNonGenericCollectionsPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ImmutableWithNonGenericCollectionsPojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(pojo, ImmutableWithNonGenericCollectionsPojo.class);
Collection<?> nonGenerifiedCollection = pojo.getNonGenerifiedCollection();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(nonGenerifiedCollection, Object.class, ImmutableWithNonGenericCollectionsPojo.NBR_ELEMENTS);
Set<?> nonGenerifiedSet = pojo.getNonGenerifiedSet();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(nonGenerifiedSet, Object.class, ImmutableWithNonGenericCollectionsPojo.NBR_ELEMENTS);
Map<?, ?> nonGenerifiedMap = pojo.getNonGenerifiedMap();
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(nonGenerifiedMap, Object.class, Object.class, ImmutableWithNonGenericCollectionsPojo.NBR_ELEMENTS);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class CollectionsTest method podamShouldHandleImmutablePojoWithGenerifiedCollectionsInConstructor.
@Test
@Title("Podam should handle immutable POJOs with generified collections in the constructor")
public void podamShouldHandleImmutablePojoWithGenerifiedCollectionsInConstructor() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ImmutableWithGenericCollectionsPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ImmutableWithGenericCollectionsPojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(pojo, ImmutableWithGenericCollectionsPojo.class);
Collection<OneDimensionalTestPojo> generifiedCollection = pojo.getGenerifiedCollection();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(generifiedCollection, OneDimensionalTestPojo.class, ImmutableWithNonGenericCollectionsPojo.NBR_ELEMENTS);
Map<String, Calendar> generifiedMap = pojo.getGenerifiedMap();
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(generifiedMap, String.class, GregorianCalendar.class, ImmutableWithNonGenericCollectionsPojo.NBR_ELEMENTS);
Set<ImmutableWithNonGenericCollectionsPojo> generifiedSet = pojo.getGenerifiedSet();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(generifiedSet, ImmutableWithNonGenericCollectionsPojo.class, ImmutableWithNonGenericCollectionsPojo.NBR_ELEMENTS);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class PodamFactoryBasicTypesTest method podamShouldSupportRecursiveLists.
@Test
@Title("Podam should fill in lists of the containing class type")
public void podamShouldSupportRecursiveLists() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
RecursiveList recursiveListPojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(RecursiveList.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(recursiveListPojo, RecursiveList.class);
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(recursiveListPojo.getList(), RecursiveList.class);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class AnnotationsTest method podamShouldNotFillFieldsAnnotatedWithExcludeAnnotation.
@Test
@Title("Podam should not fill POJO's attributes annotated with @PodamExclude")
public void podamShouldNotFillFieldsAnnotatedWithExcludeAnnotation() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ExcludeAnnotationPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ExcludeAnnotationPojo.class, podamFactory);
podamValidationSteps.theObjectShouldNotBeNull(pojo);
podamValidationSteps.theIntFieldShouldNotBeZero(pojo.getIntField());
podamValidationSteps.anyFieldWithPodamExcludeAnnotationShouldBeNull(pojo.getSomePojo());
}
Aggregations