use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class CollectionsTest method podamShouldBeAbleToFillInPojosWithRawTypeCollectionAttributesAndDefaultValueToObject.
@Test
@Title("Podam should be able to fill in POJOs with raw type collection attributes and default values to Object")
public void podamShouldBeAbleToFillInPojosWithRawTypeCollectionAttributesAndDefaultValueToObject() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ReadOnlyRawFieldsPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ReadOnlyRawFieldsPojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(pojo, ReadOnlyRawFieldsPojo.class);
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getList(), Object.class);
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getMap(), Object.class, Object.class);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class CollectionsTest method podamShouldHandleStandardCollections.
@Test
@Title("Podam should handle standard collections")
public void podamShouldHandleStandardCollections() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
CollectionsPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(CollectionsPojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(pojo, CollectionsPojo.class);
List<String> strList = pojo.getStrList();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(strList, String.class);
ArrayList<String> arrayListStr = pojo.getArrayListStr();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(arrayListStr, String.class);
List<String> copyOnWriteList = pojo.getCopyOnWriteList();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(copyOnWriteList, String.class);
HashSet<String> hashSetStr = pojo.getHashSetStr();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(hashSetStr, String.class);
List<String> listStrCollection = new ArrayList<String>(pojo.getStrCollection());
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(listStrCollection, String.class);
Set<String> setStrCollection = new HashSet<String>(pojo.getStrCollection());
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(setStrCollection, String.class);
Set<String> strSet = pojo.getStrSet();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(strSet, String.class);
Map<String, OneDimensionalTestPojo> map = pojo.getMap();
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(map, String.class, OneDimensionalTestPojo.class);
HashMap<String, OneDimensionalTestPojo> hashMap = pojo.getHashMap();
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(hashMap, String.class, OneDimensionalTestPojo.class);
ConcurrentMap<String, OneDimensionalTestPojo> concurrentHashMap = pojo.getConcurrentHashMap();
podamValidationSteps.thePojoMustBeOfTheType(concurrentHashMap, ConcurrentHashMap.class);
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(concurrentHashMap, String.class, OneDimensionalTestPojo.class);
ConcurrentHashMap<String, OneDimensionalTestPojo> concurrentHashMapImpl = pojo.getConcurrentHashMapImpl();
podamValidationSteps.thePojoMustBeOfTheType(concurrentHashMapImpl, ConcurrentHashMap.class);
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(concurrentHashMapImpl, String.class, OneDimensionalTestPojo.class);
Queue<SimplePojoToTestSetters> queue = pojo.getQueue();
podamValidationSteps.thePojoMustBeOfTheType(queue, LinkedList.class);
SimplePojoToTestSetters pojoQueueElement = queue.poll();
podamValidationSteps.thePojoMustBeOfTheType(pojoQueueElement, SimplePojoToTestSetters.class);
List<?> nonGenerifiedList = pojo.getNonGenerifiedList();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(nonGenerifiedList, Object.class);
List<?> looseCoupledNonGenerifiedList = pojo.getLooseCoupledNonGenerifiedList();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(looseCoupledNonGenerifiedList, Object.class);
Set<?> looseCoupledNonGenerifiedSet = pojo.getLooseCoupledNonGenerifiedSet();
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(looseCoupledNonGenerifiedSet, Object.class);
Map<?, ?> nonGenerifiedMap = pojo.getNonGenerifiedMap();
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(nonGenerifiedMap, Object.class, Object.class);
Map<?, ?> looseCoupledNonGenerifiedMap = pojo.getLooseCoupledNonGenerifiedMap();
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(looseCoupledNonGenerifiedMap, Object.class, Object.class);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class ConstructorsUnitTest method podamShouldHandleConstructorsWithMultipleGenericsDuringPojoInstantiation.
@Test
@Title("Podam should handle constructors with multiple generics during Pojo instantiation")
public void podamShouldHandleConstructorsWithMultipleGenericsDuringPojoInstantiation() {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
MultipleGenericInConstructorPojo<?, ?, ?, ?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(MultipleGenericInConstructorPojo.class, podamFactory, String.class, Character.class, Byte.class, Integer.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo, MultipleGenericInConstructorPojo.class);
podamValidationSteps.theTwoObjectsShouldBeEqual(String.class, pojo.getType());
podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getList(), Character.class);
podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getMap(), Byte.class, Integer.class);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class ConstructorsUnitTest method podamShouldBeAbleToInstantiatePojosWithImmutableMaps.
@Test
@Title("Podam should be able to instantiate POJOs with immutable Maps")
public void podamShouldBeAbleToInstantiatePojosWithImmutableMaps() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ImmutableHashtable<?, ?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(ImmutableHashtable.class, podamFactory, String.class, Integer.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo, ImmutableHashtable.class);
podamValidationSteps.theMapShouldBeEmtpy(pojo);
}
use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.
the class ConstructorsUnitTest method podamShouldChooseTheFullestConstructorWhenInvokedForFullData.
@Test
@Title("Podam should choose the fullest constructor when invoked for full data")
public void podamShouldChooseTheFullestConstructorWhenInvokedForFullData() throws Exception {
PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
ImmutablePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClassWithFullConstructor(ImmutablePojo.class, podamFactory);
podamValidationSteps.thePojoMustBeOfTheType(pojo, ImmutablePojo.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo.getValue(), String.class);
podamValidationSteps.thePojoMustBeOfTheType(pojo.getValue2(), Integer.class);
}
Aggregations