Search in sources :

Example 66 with PodamFactory

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

Example 67 with PodamFactory

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

Example 68 with PodamFactory

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

Example 69 with PodamFactory

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

Example 70 with PodamFactory

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());
}
Also used : DataProviderStrategy(uk.co.jemos.podam.api.DataProviderStrategy) PodamFactory(uk.co.jemos.podam.api.PodamFactory)

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