@Test public void testUniqueNullAttributeSlayerAPI() { final ComposedTypeModel typeUnderInvestigation = typeService.getComposedTypeForClass(LinkModel.class); final AttributeDescriptorModel attributeDesc = typeService.getAttributeDescriptor(typeUnderInvestigation, LinkModel.LANGUAGE); Assert.assertTrue(attributeDesc.getOptional().booleanValue()); Assert.assertTrue(attributeDesc.getUnique().booleanValue()); final LinkModel link1 = modelService.create(LinkModel.class); link1.setQualifier("link1"); link1.setSource(source); link1.setTarget(target); // the optional unique attribute link1.setLanguage(language); modelService.save(link1); // <-- OK! final LinkModel link2 = modelService.create(LinkModel.class); link2.setQualifier("link2"); link2.setSource(source); link2.setTarget(target); // the optional unique attribute link2.setLanguage(null); modelService.save(link2); // <-- OK! //<-- still OK, only one null value! final LinkModel link3 = modelService.create(LinkModel.class); link3.setQualifier("link3"); link3.setSource(source); link3.setTarget(target); // the optional unique attribute link3.setLanguage(null); boolean success = false; try { modelService.save(link3); // <-- what happens now?! Assert.fail( "Should have failed with 'ModelSavingException' for ambiguous unique attribute, which is 'null'"); } catch (final ModelSavingException e) { success = true; } Assert.assertTrue( "Should have failed with 'ModelSavingException' for ambiguous unique attribute, which is 'null'", success); }