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