Search in sources :

Example 6 with PodamFactory

use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.

the class AbnormalPojosTest method podamShouldFillEmbeddedAbstractClassesIfAConcreteTypeHasBeenSpecified.

@Test
@Title("Podam should fill embedded abstract classes if a concrete type has been specified")
public void podamShouldFillEmbeddedAbstractClassesIfAConcreteTypeHasBeenSpecified() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    podamStrategySteps.addOrReplaceSpecific(podamFactory, AbstractTestPojo.class, ConcreteTestPojo.class);
    EmbeddedAbstractFieldTestPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(EmbeddedAbstractFieldTestPojo.class, podamFactory);
    podamValidationSteps.thePojoMustBeOfTheType(pojo, EmbeddedAbstractFieldTestPojo.class);
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getPojo(), AbstractTestPojo.class);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 7 with PodamFactory

use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.

the class ExtensionsTest method podamShouldCreatePojosInAccordanceWithCustomDataProviderStrategies.

@Test
@Title("Podam should create POJOs in accordance with custom data provider strategies")
public void podamShouldCreatePojosInAccordanceWithCustomDataProviderStrategies() throws Exception {
    CustomRandomDataProviderStrategy strategy = podamFactorySteps.givenACustomRandomDataProviderStrategy();
    PodamFactory podamFactory = podamFactorySteps.givenAPodamFactoryWithCustomDataProviderStrategy(strategy);
    PojoWithMapsAndCollections pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(PojoWithMapsAndCollections.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    podamValidationSteps.theArrayOfTheGivenTypeShouldNotBeNullOrEmptyAndContainExactlyTheGivenNumberOfElements(pojo.getArray(), 2, String.class);
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(pojo.getList(), Boolean.class, 3);
    podamValidationSteps.theMapShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(pojo.getMap(), Integer.class, Long.class, 4);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) PojoWithMapsAndCollections(uk.co.jemos.podam.test.dto.PojoWithMapsAndCollections) CustomRandomDataProviderStrategy(uk.co.jemos.podam.test.strategies.CustomRandomDataProviderStrategy) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 8 with PodamFactory

use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.

the class InheritanceTest method podamShouldManufactureAllPojosInATreeHierarchy.

@Test
@Title("Podam should manufacture all POJOs in a tree hierarchy")
public void podamShouldManufactureAllPojosInATreeHierarchy() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    A pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(A.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    B b = pojo.getB();
    podamValidationSteps.theObjectShouldNotBeNull(b);
    podamValidationSteps.theObjectShouldNotBeNull(b.getCustomValue());
}
Also used : A(uk.co.jemos.podam.test.dto.pdm42.A) B(uk.co.jemos.podam.test.dto.pdm42.B) PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 9 with PodamFactory

use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.

the class MultipleInterfacesInheritanceTest method podamCannotInstantiateInterfaces.

@Test
@Title("Podam cannot instantiate interfaces")
public void podamCannotInstantiateInterfaces() throws Exception {
    PodamFactory podamFactory = provideCustomisedPodamFactory();
    MultipleInterfacesListPojo<?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(MultipleInterfacesListPojo.class, podamFactory, String.class);
    podamValidationSteps.theObjectShouldBeNull(pojo);
    List<Class<?>> accessed = ((CustomDataProviderStrategy) podamFactory.getStrategy()).getAccessed();
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(accessed, Class.class, 1);
    podamValidationSteps.theTwoObjectsShouldBeEqual(MultipleInterfacesListPojo.class, accessed.get(0));
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 10 with PodamFactory

use of uk.co.jemos.podam.api.PodamFactory in project podam by devopsfolks.

the class MultipleInterfacesInheritanceTest method testHolderOfPojoWithMultiInterfaces.

@Test
@Title("Podam will create an instance of a POJO but its interface types won't be instantiated")
public void testHolderOfPojoWithMultiInterfaces() throws Exception {
    PodamFactory podamFactory = provideCustomisedPodamFactory();
    MultipleInterfacesHolderPojo<?, ?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(MultipleInterfacesHolderPojo.class, podamFactory, String.class, Long.class);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    podamValidationSteps.theObjectShouldBeNull(pojo.getList());
    podamValidationSteps.theObjectShouldBeNull(pojo.getMap());
    List<Class<?>> accessed = ((CustomDataProviderStrategy) podamFactory.getStrategy()).getAccessed();
    podamValidationSteps.theTwoObjectsShouldBeEqual(accessed.size(), 2);
    podamValidationSteps.theCollectionShouldContainAtLeastOneElementOfType(accessed, MultipleInterfacesListPojo.class);
    podamValidationSteps.theCollectionShouldContainAtLeastOneElementOfType(accessed, MultipleInterfacesMapPojo.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