@Test
public void should_validate_beans_before_saving_them() throws Exception {

    doThrow(ConstraintValidationException.class).when(validator).validate(any(Object.class));
    try {
        repository.save(repoDirectory, new SimpleDesignerArtifact("object1", "object1", 1));
        failBecauseExceptionWasNotThrown(ConstraintValidationException.class);
    } catch (ConstraintValidationException e) {
        // should not have saved object1
        assertThat(repoDirectory.resolve("object1.json").toFile()).doesNotExist();
    }
}