use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class ConstructorsUnitTest method podamShouldHandleGenericCollectionsInConstructorWithMemoizationEnabled.
@Test
@Title("Podam should correctly handle generic collections in constructor with memoization enabled")
public void podamShouldHandleGenericCollectionsInConstructorWithMemoizationEnabled() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactoryWithMemoizationEnabled();
GenericCollectionsConstructorPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(GenericCollectionsConstructorPojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(pojo, GenericCollectionsConstructorPojo.class);
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getList1(), Long.class);
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getList2(), String.class);
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getList3(), Integer.class);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class ConstructorsUnitTest method podamShouldCreateInstancesOfGenericPojosWithFactoryMethodsWhenTheConcreteTypeIsKnown.
@Test
@Title("Podam should be able to create instances of generic POJOs with factory methods when the concrete type is known")
public void podamShouldCreateInstancesOfGenericPojosWithFactoryMethodsWhenTheConcreteTypeIsKnown() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
FactoryInstantiablePojo<?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(FactoryInstantiablePojo.class, podamFactory, Date.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo, FactoryInstantiablePojo.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo.getTypedValue(), Date.class);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class ReadOnlyComplexTypesTest method podamShouldFillReadOnlyComplexTypes.
@Test
@Title("Podam should fill in complex (e.g. with more than two generic types), read-only POJOs")
public void podamShouldFillReadOnlyComplexTypes() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ReadOnlyGenericComplexTypesPojo<?, ?, ?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(ReadOnlyGenericComplexTypesPojo.class, podamFactory, Character.class, Long.class, Integer.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo, ReadOnlyGenericComplexTypesPojo.class);
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getList(), Long.class);
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getMap(), Integer.class, String.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo.getValue(), ReadOnlyGenericComplexTypesPojo.Value.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo.getValue().getValue(), Character.class);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class CollectionsTest method podamShouldHandlePojosWithNoSettersAndCollectionsInTheConstructor.
@Test
@Title("Podam should handle POJOs with no setters and collections in the constructor")
public void podamShouldHandlePojosWithNoSettersAndCollectionsInTheConstructor() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
CollectionReadOnlyPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(CollectionReadOnlyPojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(pojo, CollectionReadOnlyPojo.class);
List<Date> dates = pojo.getDates();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(dates, Date.class, 2);
List<String> strList = pojo.getStrList();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(strList, String.class, 5);
int intField = pojo.getIntField();
podamValidationSteps.theIntFieldShouldNotBeZero(intField);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class CollectionsTest method testMap.
//------------------> Private methods
private void testMap(Class<? extends Map> mapType) {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
DataProviderStrategy strategy = podamFactory.getStrategy();
int mapSize = strategy.getNumberOfCollectionElements(PodamTestInterface.class);
if (ConcurrentMap.class.isAssignableFrom(mapType)) {
mapSize = 0;
}
Map<?, ?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(mapType, podamFactory, String.class, PodamTestInterface.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo, Map.class);
podamValidationSteps.theTwoObjectsShouldBeEqual(mapSize, pojo.keySet().size());
podamValidationSteps.theTwoObjectsShouldBeEqual(mapSize, pojo.values().size());
}
Aggregations