Package info.archinnov.achilles.test.integration.entity

Examples of info.archinnov.achilles.test.integration.entity.EntityWithClassLevelConstraint


    @Test
    public void should_validate_entity_constrained_on_class() throws Exception {
        // Given
        Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
        EntityWithClassLevelConstraint entity = new EntityWithClassLevelConstraint();
        entity.setId(id);
        entity.setFirstname("firstname");
        entity.setLastname("lastname");
        manager.insert(entity);

        // When
        EntityWithClassLevelConstraint found = manager.find(EntityWithClassLevelConstraint.class, id);

        // Then
        assertThat(found).isNotNull();
        assertThat(found.getFirstname()).isEqualTo("firstname");
        assertThat(found.getLastname()).isEqualTo("lastname");
    }
View Full Code Here


    @Test
    public void should_error_on_invalid_class_persist() throws Exception {
        // Given
        boolean exceptionRaised = false;
        Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
        EntityWithClassLevelConstraint entity = new EntityWithClassLevelConstraint();
        entity.setId(id);
        entity.setFirstname("fn");

        StringBuilder errorMessage = new StringBuilder("Bean validation error : \n");
        errorMessage.append("\tfirstname and lastname should not be blank for class '");
        errorMessage.append(EntityWithClassLevelConstraint.class.getCanonicalName()).append("'");
View Full Code Here

    @Test
    public void should_error_on_invalid_class_update() throws Exception {
        // Given
        boolean exceptionRaised = false;
        Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
        EntityWithClassLevelConstraint entity = new EntityWithClassLevelConstraint();
        entity.setId(id);
        entity.setFirstname("fn");
        entity.setLastname("ln");

        StringBuilder errorMessage = new StringBuilder("Bean validation error : \n");
        errorMessage.append("\tfirstname and lastname should not be blank for class '");
        errorMessage.append(EntityWithClassLevelConstraint.class.getCanonicalName()).append("'");

        EntityWithClassLevelConstraint managedEntity = manager.insert(entity);

        try {
            // When
            managedEntity.setFirstname(null);
            manager.update(managedEntity);
        } catch (AchillesBeanValidationException ex) {
            // Then
            assertThat(ex.getMessage()).contains(errorMessage.toString());
            exceptionRaised = true;
View Full Code Here

TOP

Related Classes of info.archinnov.achilles.test.integration.entity.EntityWithClassLevelConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.