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

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


    @Test
    public void should_validate_entity_constrained_on_property() throws Exception {
        // Given
        Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
        EntityWithPropertyLevelConstraint entity = new EntityWithPropertyLevelConstraint();
        entity.setId(id);
        entity.setName("name");
        manager.insert(entity);

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

        // Then
        assertThat(found).isNotNull();
        assertThat(found.getName()).isEqualTo("name");
    }
View Full Code Here


    @Test
    public void should_error_on_invalid_property_persist() throws Exception {
        // Given
        boolean exceptionRaised = false;
        Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
        EntityWithPropertyLevelConstraint entity = new EntityWithPropertyLevelConstraint();
        entity.setId(id);

        StringBuilder errorMessage = new StringBuilder("Bean validation error : \n");
        errorMessage.append("\tproperty 'name' of class '");
        errorMessage.append(EntityWithPropertyLevelConstraint.class.getCanonicalName()).append("'");
View Full Code Here

    @Test
    public void should_error_on_invalid_property_update() throws Exception {
        // Given
        boolean exceptionRaised = false;
        Long id = RandomUtils.nextLong(0,Long.MAX_VALUE);
        EntityWithPropertyLevelConstraint entity = new EntityWithPropertyLevelConstraint();
        entity.setId(id);
        entity.setName("name");

        StringBuilder errorMessage = new StringBuilder("Bean validation error : \n");
        errorMessage.append("\tproperty 'name' of class '");
        errorMessage.append(EntityWithPropertyLevelConstraint.class.getCanonicalName()).append("'");
        EntityWithPropertyLevelConstraint managedEntity = manager.insert(entity);

        try {
            // When
            managedEntity.setName(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.EntityWithPropertyLevelConstraint

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.