Search in sources :

Example 1 with ValidationPojoForStringWithSizeAndNoMax

use of uk.co.jemos.podam.test.dto.ValidationPojoForStringWithSizeAndNoMax in project podam by devopsfolks.

the class ValidatedPojoTest method whenMaxLengthIsNotSpecifiedInSizeAnnotationPodamShouldAssignASensibleDefault.

@Test
@Title("When the @Size annotation doesn't have a max length specified, Podam should assign a sensible value")
public void whenMaxLengthIsNotSpecifiedInSizeAnnotationPodamShouldAssignASensibleDefault() throws Exception {
    PodamFactory podamFactory = podamFactorySteps.givenAPodamWithACustomTypeManufacturer(String.class, stringTypeManufacturer);
    ValidationPojoForStringWithSizeAndNoMax pojo = podamInvocationSteps.whenIInvokeTheFactoryForClass(ValidationPojoForStringWithSizeAndNoMax.class, podamFactory);
    podamValidationSteps.theObjectShouldNotBeNull(pojo);
    podamValidationSteps.theCollectionShouldBeEmpty(stringTypeManufacturer.calls);
    Validator validator = podamFactorySteps.givenAJavaxValidator();
    validatorSteps.thePojoShouldNotViolateAnyValidations(validator, pojo);
}
Also used : PodamFactory(uk.co.jemos.podam.api.PodamFactory) ValidationPojoForStringWithSizeAndNoMax(uk.co.jemos.podam.test.dto.ValidationPojoForStringWithSizeAndNoMax) Validator(javax.validation.Validator) Test(org.junit.Test) Title(net.thucydides.core.annotations.Title)

Example 2 with ValidationPojoForStringWithSizeAndNoMax

use of uk.co.jemos.podam.test.dto.ValidationPojoForStringWithSizeAndNoMax 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 ValidationPojoForStringWithSizeAndNoMax (uk.co.jemos.podam.test.dto.ValidationPojoForStringWithSizeAndNoMax)2 Validator (javax.validation.Validator)1 AnnotationStrategy (uk.co.jemos.podam.test.strategies.AnnotationStrategy)1