/** * @see VisitAttributeTypeController#delete(String, String, javax.servlet.http.HttpServletRequest, * HttpServletResponse) */ @Test public void delete_shouldRetireAVisitAttributeType() throws Exception { VisitAttributeType visitAttributeType = service.getVisitAttributeType(1); Assert.assertFalse(visitAttributeType.isRetired()); controller.delete( Rest19ExtTestConstants.VISIT_ATTRIBUTE_TYPE_UUID, "test", emptyRequest(), emptyResponse()); visitAttributeType = service.getVisitAttributeType(1); Assert.assertTrue(visitAttributeType.isRetired()); Assert.assertEquals("test", visitAttributeType.getRetireReason()); }
/** @see {@link VisitAttributeTypeValidator#validate(Object,Errors)} */ @Test @Verifies( value = "should fail validation if field lengths are not correct", method = "validate(Object,Errors)") public void validate_shouldFailValidationIfFieldLengthsAreNotCorrect() throws Exception { VisitAttributeType visitAttributeType = new VisitAttributeType(); visitAttributeType.setName( "too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text"); visitAttributeType.setMinOccurs(1); visitAttributeType.setDatatypeConfig("[a-z]+"); visitAttributeType.setDatatypeClassname( "too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text"); visitAttributeType.setDescription(new String(new char[66000])); visitAttributeType.setPreferredHandlerClassname( "too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text"); visitAttributeType.setRetireReason( "too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text too long text"); Errors errors = new BindException(visitAttributeType, "visitAttributeType"); new VisitAttributeTypeValidator().validate(visitAttributeType, errors); Assert.assertTrue(errors.hasFieldErrors("name")); Assert.assertTrue(errors.hasFieldErrors("description")); Assert.assertTrue(errors.hasFieldErrors("datatypeClassname")); Assert.assertTrue(errors.hasFieldErrors("preferredHandlerClassname")); Assert.assertTrue(errors.hasFieldErrors("retireReason")); }
/** * @see {@link VisitAttributeTypeValidator#validate(Object, * org.springframework.validation.Errors)} */ @Test @Verifies( value = "should pass validation if field lengths are correct", method = "validate(Object,Errors)") public void validate_shouldPassValidationIfFieldLengthsAreCorrect() throws Exception { VisitAttributeType visitAttributeType = new VisitAttributeType(); visitAttributeType.setName("name"); visitAttributeType.setMinOccurs(1); visitAttributeType.setDatatypeConfig("[a-z]+"); visitAttributeType.setDatatypeClassname(RegexValidatedTextDatatype.class.getName()); visitAttributeType.setDescription("some text"); visitAttributeType.setRetireReason("some text"); Errors errors = new BindException(visitAttributeType, "visitAttributeType"); new VisitAttributeTypeValidator().validate(visitAttributeType, errors); Assert.assertFalse(errors.hasErrors()); }