Search in sources :

Example 76 with PodamFactory

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

the class RandomDataProviderStrategyImplInitialisationUnitTest method podamShouldCreatePojosInAccordanceWithCustomDataProviderStrategies.

@Test
@Title("Podam should create POJOs in accordance with custom data provider strategies")
public void podamShouldCreatePojosInAccordanceWithCustomDataProviderStrategies() throws Exception {
    DataProviderStrategy 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 : DataProviderStrategy(uk.co.jemos.podam.api.DataProviderStrategy) AbstractRandomDataProviderStrategy(uk.co.jemos.podam.api.AbstractRandomDataProviderStrategy) PodamFactory(uk.co.jemos.podam.api.PodamFactory) PojoWithMapsAndCollections(uk.co.jemos.podam.test.dto.PojoWithMapsAndCollections) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 77 with PodamFactory

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

the class AbnormalPojosTest method podamCannotHandleCircularConstructors.

@Test
@Title("Invoking Podam on a POJO with a circular constructor (e.g. java.net.URL) leads to a null POJO")
public void podamCannotHandleCircularConstructors() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAStandardPodamFactory();
    URL pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(URL.class, podamFactory);
    podamValidationSteps.thePojoShouldBeNull(pojo);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) URL(java.net.URL) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 78 with PodamFactory

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

the class ExtensionsTest method podamShouldCreateInputStreamWithCustomTypeManufacturer.

@Test
@Title("Podam should create InputStream with the custom type manufacturer")
public void podamShouldCreateInputStreamWithCustomTypeManufacturer() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAPodamWithAInputStreamTypeManufacturer();
    InputStream inputStream = podamInvocationSteps.whenIInvokeTheFactoryForClass(InputStream.class, podamFactory);
    podamValidationSteps.thePojoMustBeOfTheType(inputStream, InputStream.class);
    podamInvocationSteps.whenIRemoveTypeManufacturer(podamFactory, InputStream.class);
    InputStream inputStream2 = podamInvocationSteps.whenIInvokeTheFactoryForClass(InputStream.class, podamFactory);
    podamValidationSteps.theObjectShouldBeNull(inputStream2);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) InputStream(java.io.InputStream) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 79 with PodamFactory

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

the class ExtensionsTest method podamShouldFillTheAttributeMetadataWithTheAttributeNames.

@Test
@Title("Podam should fill AttributeMetadata with the attribute name")
public void podamShouldFillTheAttributeMetadataWithTheAttributeNames() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAPodamWithACustomStringTypeManufacturer();
    PojoClassic pojoClassic = podamInvocationSteps.whenIInvokeTheFactoryForClass(PojoClassic.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojoClassic);
    PojoSpecific pojoSpecific = podamInvocationSteps.whenIInvokeTheFactoryForClass(PojoSpecific.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojoSpecific);
    podamValidationSteps.theStringValueShouldBeExactly(pojoClassic.getAtt(), "classic");
    podamValidationSteps.theStringValueShouldBeExactly(pojoSpecific.getAtt(), "specific");
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) PojoClassic(uk.co.jemos.podam.test.dto.annotations.PojoClassic) PojoSpecific(uk.co.jemos.podam.test.dto.annotations.PojoSpecific) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 80 with PodamFactory

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

the class ExtensionsTest method podamShouldCreateTimestampWithCustomTypeManufacturer.

@Test
@Title("Podam should create Timestamp with the custom type manufacturer")
public void podamShouldCreateTimestampWithCustomTypeManufacturer() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAPodamWithACustomIntegerTypeManufacturer();
    Timestamp timestamp = podamInvocationSteps.whenIInvokeTheFactoryForClass(Timestamp.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(timestamp);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) Timestamp(java.sql.Timestamp) 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