Search in sources :

Example 16 with PodamFactory

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

the class MemoizationTest method memoizationShouldWorkCorrectlyForCollectionsAndArrays.

@Test
@Title("Memoization should work correctly for collections and arrays")
public void memoizationShouldWorkCorrectlyForCollectionsAndArrays() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactoryWithMemoizationEnabled();
    podamValidationSteps.theMemoizationShouldBeEnabled(podamFactory.getStrategy(), true);
    MemoizationPojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(MemoizationPojo.class, podamFactory);
    podamValidationSteps.thePojoMustBeOfTheType(pojo, MemoizationPojo.class);
    podamValidationSteps.theArrayOfTheGivenTypeShouldNotBeNullOrEmptyAndContainExactlyTheGivenNumberOfElements(pojo.getArray(), podamFactory.getStrategy().getNumberOfCollectionElements(Currency.class), Currency.class);
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(pojo.getCollection(), Currency.class, podamFactory.getStrategy().getNumberOfCollectionElements(Currency.class));
    podamValidationSteps.theMapShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(pojo.getMap(), Currency.class, Currency.class, podamFactory.getStrategy().getNumberOfCollectionElements(Currency.class));
}
Also used : MemoizationPojo(uk.co.jemos.podam.test.dto.MemoizationPojo) PodamFactory(uk.co.jemos.podam.api.PodamFactory) Currency(java.util.Currency) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 17 with PodamFactory

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

the class MemoizationTest method whenMemoizationIsFalsePodamShouldReturnDifferentInstancesForDifferentInvocations.

@Test
@Title("When memoization is set to false Podam should return different instances for different invocations")
public void whenMemoizationIsFalsePodamShouldReturnDifferentInstancesForDifferentInvocations() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    podamFactory.getStrategy().setMemoization(false);
    podamValidationSteps.theMemoizationShouldBeEnabled(podamFactory.getStrategy(), false);
    SimplePojoToTestSetters pojo1 = podamInvocationSteps.whenIInvokeTheFactoryForClass(SimplePojoToTestSetters.class, podamFactory);
    podamValidationSteps.thePojoMustBeOfTheType(pojo1, SimplePojoToTestSetters.class);
    SimplePojoToTestSetters pojo2 = podamInvocationSteps.whenIInvokeTheFactoryForClass(SimplePojoToTestSetters.class, podamFactory);
    podamValidationSteps.thePojoMustBeOfTheType(pojo2, SimplePojoToTestSetters.class);
    podamValidationSteps.theTwoObjectsShouldBeDifferent(pojo1, pojo2);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) SimplePojoToTestSetters(uk.co.jemos.podam.test.dto.SimplePojoToTestSetters) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 18 with PodamFactory

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

the class MemoizationTest method memoizationShouldWorkForRecursivePojos.

@Test
@Title("Memoization should work for recursive Pojos")
public void memoizationShouldWorkForRecursivePojos() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactoryWithMemoizationEnabled();
    podamValidationSteps.theMemoizationShouldBeEnabled(podamFactory.getStrategy(), true);
    RecursivePojo pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(RecursivePojo.class, podamFactory);
    podamValidationSteps.thePojoMustBeOfTheType(pojo, RecursivePojo.class);
    podamValidationSteps.theTwoObjectsShouldBeStrictlyEqual(pojo, pojo.getParent());
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) RecursivePojo(uk.co.jemos.podam.test.dto.RecursivePojo) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 19 with PodamFactory

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

the class ConstructorsUnitTest method podamShouldCreateInstancesOfPojosExtendingGenericClasses.

@Test
@Title("Podam should create instances of POJOs extending generic classes")
public void podamShouldCreateInstancesOfPojosExtendingGenericClasses() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    TypedClassPojo2 pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(TypedClassPojo2.class, podamFactory);
    podamValidationSteps.thePojoMustBeOfTheType(pojo, TypedClassPojo2.class);
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getTypedValue(), String.class);
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndContainElementsOfType(pojo.getTypedList(), String.class);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 20 with PodamFactory

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

the class ConstructorsUnitTest method podamShouldCreateInstancesOfJAXBElementsDeclaredAsInstanceVariablesInAPojo.

@Test
@Title("Podam should be able to create instances of JAXBElements declared as instance variables in a POJO")
public void podamShouldCreateInstancesOfJAXBElementsDeclaredAsInstanceVariablesInAPojo() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    JAXBElementPojo<?> pojo = podamInvocationSteps.whenIInvokeTheFactoryForGenericTypeWithSpecificType(JAXBElementPojo.class, podamFactory, String.class);
    podamValidationSteps.thePojoMustBeOfTheType(pojo, JAXBElementPojo.class);
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getValue(), JAXBElement.class);
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getValue().getName(), QName.class);
    podamValidationSteps.thePojoMustBeOfTheType(pojo.getValue().getValue(), String.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