Search in sources :

Example 1 with NaturalNumber

use of io.spine.test.entity.number.NaturalNumber in project core-java by SpineEventEngine.

the class AbstractEntityShould method throw_InvalidEntityStateException_if_state_is_invalid.

@Test
public void throw_InvalidEntityStateException_if_state_is_invalid() {
    final NaturalNumberEntity entity = new NaturalNumberEntity(0L);
    final NaturalNumber invalidNaturalNumber = newNaturalNumber(-1);
    try {
        // This should pass.
        entity.updateState(newNaturalNumber(1));
        // This should fail.
        entity.updateState(invalidNaturalNumber);
        fail("Exception expected.");
    } catch (InvalidEntityStateException e) {
        assertSize(1, e.getError().getValidationError().getConstraintViolationList());
    }
}
Also used : InvalidEntityStateException(io.spine.server.entity.InvalidEntityStateException) NaturalNumber(io.spine.test.entity.number.NaturalNumber) Test(org.junit.Test)

Aggregations

InvalidEntityStateException (io.spine.server.entity.InvalidEntityStateException)1 NaturalNumber (io.spine.test.entity.number.NaturalNumber)1 Test (org.junit.Test)1