Search in sources :

Example 1 with AnnotationStrategy

use of uk.co.jemos.podam.test.strategies.AnnotationStrategy in project podam by devopsfolks.

the class AnnotationsTest method podamShouldHandlePojosWithAnnotatedFieldsAndCustomGenericAnnotationStrategy.

@Test
@Title("Podam should handle POJOs with multiple annotated fields and custom generic annotation strategy")
public void podamShouldHandlePojosWithAnnotatedFieldsAndCustomGenericAnnotationStrategy() throws Exception {
    AnnotationStrategy annotationStrategy = new AnnotationStrategy();
    PodamFactory podamFactory = podamFactorySteps.givenAPodamFactoryWithCustomStrategy(Annotation.class, annotationStrategy);
    AnnotationStrategy basicAnnotationStrategy = new AnnotationStrategy();
    podamFactorySteps.addCustomStrategy(podamFactory, Basic.class, basicAnnotationStrategy);
    SimplePojoWithMultipleAnnotationsToAttribute pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(SimplePojoWithMultipleAnnotationsToAttribute.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(annotationStrategy.getRecordedCalls(), List.class, 1);
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(annotationStrategy.getRecordedCalls().get(0), Annotation.class, 1);
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(basicAnnotationStrategy.getRecordedCalls(), List.class, 2);
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(basicAnnotationStrategy.getRecordedCalls().get(0), Annotation.class, 2);
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(basicAnnotationStrategy.getRecordedCalls().get(1), Annotation.class, 2);
}
Also used : AnnotationStrategy(uk.co.jemos.podam.test.strategies.AnnotationStrategy) PodamFactory(uk.co.jemos.podam.api.PodamFactory) SimplePojoWithMultipleAnnotationsToAttribute(uk.co.jemos.podam.test.dto.SimplePojoWithMultipleAnnotationsToAttribute) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 2 with AnnotationStrategy

use of uk.co.jemos.podam.test.strategies.AnnotationStrategy in project podam by devopsfolks.

the class ValidatedPojoTest method whenTheAnnotationStrategyAndTheTypeManufacturerAreSpecifiedTheFormerHasPrecedence.

@Test
@Title("When the AnnotationStrategy and the TypeManufacturer are specified, the former has precedence")
public void whenTheAnnotationStrategyAndTheTypeManufacturerAreSpecifiedTheFormerHasPrecedence() throws Exception {
    AnnotationStrategy annotationStrategy = new AnnotationStrategy();
    PodamFactory podamFactory = podamFactorySteps.givenAPodamFactoryWithCustomStrategy(Size.class, annotationStrategy);
    podamFactorySteps.addCustomTypeManufacturer(podamFactory, String.class, stringTypeManufacturer);
    ValidationPojoForStringWithSizeAndNoMax pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ValidationPojoForStringWithSizeAndNoMax.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    podamValidationSteps.theCollectionShouldBeEmpty(stringTypeManufacturer.calls);
    podamValidationSteps.theCollectionShouldNotBeNullOrEmptyAndShouldHaveExactlyTheExpectedNumberOfElements(annotationStrategy.getRecordedCalls(), List.class, 2);
}
Also used : AnnotationStrategy(uk.co.jemos.podam.test.strategies.AnnotationStrategy) PodamFactory(uk.co.jemos.podam.api.PodamFactory) ValidationPojoForStringWithSizeAndNoMax(uk.co.jemos.podam.test.dto.ValidationPojoForStringWithSizeAndNoMax) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Aggregations

Title (net.thucydides.core.annotations.Title)2 Test (org.junit.Test)2 PodamFactory (uk.co.jemos.podam.api.PodamFactory)2 AnnotationStrategy (uk.co.jemos.podam.test.strategies.AnnotationStrategy)2 SimplePojoWithMultipleAnnotationsToAttribute (uk.co.jemos.podam.test.dto.SimplePojoWithMultipleAnnotationsToAttribute)1 ValidationPojoForStringWithSizeAndNoMax (uk.co.jemos.podam.test.dto.ValidationPojoForStringWithSizeAndNoMax)1