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));
}
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);
}
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());
}
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);
}
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);
}
Aggregations