Search in sources :

Example 26 with PodamFactory

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

the class ConstructorsUnitTest method podamShouldHandleClassesWithKeyValueGenericTypes.

@Test
@Title("Podam should handle classes with generic Key/Value types")
public void podamShouldHandleClassesWithKeyValueGenericTypes() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    DefaultFieldPojo<?, ?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(DefaultFieldPojo.class, podamFactory, String.class, Long.class);
    podamValidationSteps.thePojoMustBeOfTheType(pojo, DefaultFieldPojo.class);
    podamValidationSteps.theMapShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getMap(), String.class, Long.class);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 27 with PodamFactory

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

the class ConstructorsUnitTest method podamShouldManufacturePackagePrivatePojos.

@Test
@Title("Podam should manufacture package private POJOs")
public void podamShouldManufacturePackagePrivatePojos() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    PackagePrivatePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(PackagePrivatePojo.class, podamFactory);
    podamValidationSteps.thePojoMustBeOfTheType(pojo, PackagePrivatePojo.class);
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getValue(), String.class);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 28 with PodamFactory

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

the class ConstructorsUnitTest method podamShouldBeAbleToInstantiatePojosWithImmutableCollections.

@Test
@Title("Podam should be able to instantiate POJOs with immutable Collections")
public void podamShouldBeAbleToInstantiatePojosWithImmutableCollections() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    ImmutableVector<?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(ImmutableVector.class, podamFactory, String.class);
    podamValidationSteps.theCollectionShouldBeEmpty(pojo);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 29 with PodamFactory

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

the class ExternalFactoryUnitTest method podamShouldNotCreateInstancesOfAnAbstractClassEvenIfPojoHasFullConstructor.

@Test
@Title("Podam should not be able to create instances of an Abstract class even if the POJO has a full constructor")
public void podamShouldNotCreateInstancesOfAnAbstractClassEvenIfPojoHasFullConstructor() throws Exception {
    TestExternalFactory externalFactory = (TestExternalFactory) podamFactorySteps.givenAnExternalFactory();
    PodamFactory podamFactory = podamFactorySteps.givenAdPodamFactoryWithExternalFactory(externalFactory);
    podamValidationSteps.theTwoObjectsShouldBeEqual(podamFactory.getExternalFactory(), externalFactory);
    AbstractClass pojo = podamInvocationSteps.whenIInvokeTheFactoryForClassWithFullConstructor(AbstractClass.class, podamFactory);
    podamValidationSteps.theObjectShouldBeNull(pojo);
    podamValidationSteps.theTwoObjectsShouldBeEqual(1, externalFactory.getFailures().size());
    podamValidationSteps.theTwoObjectsShouldBeEqual(AbstractClass.class, externalFactory.getFailures().get(0));
    podamValidationSteps.theTwoObjectsShouldBeEqual(1, externalFactory.getFullDataCalls().size());
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 30 with PodamFactory

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

the class ExternalFactoryUnitTest method podamShouldFillPojoInterfaceAttributeIfFullConstructorSetsItsValue.

@Test
@Title("Podam should fill POJOs and interface attributes if a full constructor sets the interface attribute value")
public void podamShouldFillPojoInterfaceAttributeIfFullConstructorSetsItsValue() throws Exception {
    TestExternalFactory externalFactory = (TestExternalFactory) podamFactorySteps.givenAnExternalFactory();
    PodamFactory podamFactory = podamFactorySteps.givenAdPodamFactoryWithExternalFactory(externalFactory);
    podamValidationSteps.theTwoObjectsShouldBeEqual(podamFactory.getExternalFactory(), externalFactory);
    PojoWithInterfaces pojo = podamInvocationSteps.whenIInvokeTheFactoryForClassWithFullConstructor(PojoWithInterfaces.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    podamValidationSteps.theTwoObjectsShouldBeEqual(2, externalFactory.getFailures().size());
    podamValidationSteps.theTwoObjectsShouldBeEqual(ObjectExt.class, externalFactory.getFailures().get(0));
    podamValidationSteps.theTwoObjectsShouldBeEqual(InterfacePojo.class, externalFactory.getFailures().get(1));
    podamValidationSteps.theTwoObjectsShouldBeEqual(2, externalFactory.getFullDataCalls().size());
}
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