@FixFor( "MODE-1525" )
@Test
public void shouldDiscoverCorrectChildNodeTypeButFailOnMandatoryPropertiesWithNoDefaultValues() throws Exception {

    session = createSession();
    InputStream cndStream = getClass().getResourceAsStream("/cnd/medical-invalid-mandatories.cnd");
    assertThat(cndStream, is(notNullValue()));
    session.getWorkspace().getNodeTypeManager().registerNodeTypes(cndStream, true);
    // Now create a person ...
    Node root = session.getRootNode();
    Node person = root.addNode("jsmith", "inf:person");
    person.setProperty("inf:firstName", "John");
    person.setProperty("inf:lastName", "Smith");
    session.save();
    Node doctor = root.addNode("drBarnes", "inf:doctor");
    doctor.setProperty("inf:firstName", "Sally");
    doctor.setProperty("inf:lastName", "Barnes");
    doctor.setProperty("inf:doctorProviderNumber", "12345678-AB");
    session.save();
    Node referral = root.addNode("referral", "nt:unstructured");
    referral.addMixin("er:eReferral");
    assertThat(referral.getMixinNodeTypes()[0].getName(), is("er:eReferral"));
    Node group = referral.addNode("er:gp");
    assertThat(group.getPrimaryNodeType().getName(), is("inf:doctor"));
    try {
        session.save();
        fail("Expected a constraint violation exception");
    } catch (ConstraintViolationException e) {
        // expected, since "inf:firstName" is mandatory but doesn't have a default value
    }
    // Set the missing mandatory properties on the node ...
    group.setProperty("inf:firstName", "Sally");
    group.setProperty("inf:lastName", "Barnes");
    // and now Session.save() will work ...
    session.save();
}