Search in sources :

Example 61 with PodamFactory

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);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 62 with PodamFactory

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);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 63 with PodamFactory

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);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 64 with PodamFactory

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);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 65 with PodamFactory

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);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Aggregations

PodamFactory (uk.co.jemos.podam.api.PodamFactory)130 Test (org.junit.Test)127 Title (net.thucydides.core.annotations.Title)126 Validator (javax.validation.Validator)4 DataProviderStrategy (uk.co.jemos.podam.api.DataProviderStrategy)3 Calendar (java.util.Calendar)2 GregorianCalendar (java.util.GregorianCalendar)2 AbstractRandomDataProviderStrategy (uk.co.jemos.podam.api.AbstractRandomDataProviderStrategy)2 PodamFactoryImpl (uk.co.jemos.podam.api.PodamFactoryImpl)2 PojoWithMapsAndCollections (uk.co.jemos.podam.test.dto.PojoWithMapsAndCollections)2 SimplePojoToTestSetters (uk.co.jemos.podam.test.dto.SimplePojoToTestSetters)2 GenericCollectionsConstructorPojo (uk.co.jemos.podam.test.dto.issue123.GenericCollectionsConstructorPojo)2 BeanContextServicesSupport (java.beans.beancontext.BeanContextServicesSupport)1 InputStream (java.io.InputStream)1 BigDecimal (java.math.BigDecimal)1 URL (java.net.URL)1 Timestamp (java.sql.Timestamp)1 Currency (java.util.Currency)1 Date (java.util.Date)1 Observable (java.util.Observable)1