TypeEditor extends DefaultEditor { @Override public Editor childNodeDeleted(String name, NodeState before) throws CommitFailedException { if (checkThisNode && effective.isMandatoryChildNode(name)) { constraintViolation(26, "Mandatory child node " + name + " can not be removed"); } return null; } TypeEditor(
            ConstraintViolationCallback callback, Set<String> typesToCheck, NodeState types,
            String primary, Iterable<String> mixins, NodeBuilder builder); private  TypeEditor(
            @NotNull TypeEditor parent, @NotNull String name,
            @Nullable String primary, @NotNull Iterable<String> mixins, @NotNull NodeBuilder builder,
            boolean validate);   TypeEditor(EffectiveType effective); static TypeEditor create(@NotNull ConstraintViolationCallback callback, Set<String> typesToCheck,
            @NotNull NodeState types, String primary, Iterable<String> mixins, 
            @NotNull NodeBuilder builder); @Override void propertyAdded(PropertyState after); @Override void propertyChanged(PropertyState before, PropertyState after); @Override void propertyDeleted(PropertyState before); @Override void enter(NodeState before, NodeState after); @Override Editor childNodeAdded(String name, NodeState after); @Override TypeEditor childNodeChanged(
            String name, NodeState before, NodeState after); @Override Editor childNodeDeleted(String name, NodeState before); static final ConstraintViolationCallback THROW_ON_CONSTRAINT_VIOLATION; static final ConstraintViolationCallback WARN_ON_CONSTRAINT_VIOLATION; }
@Test public void removeNonMandatoryChildNode() throws CommitFailedException { EffectiveType effective = createControl().createMock(EffectiveType.class); expect(effective.isMandatoryChildNode("mandatory")).andReturn(false); replay(effective); TypeEditor editor = new TypeEditor(effective); editor.childNodeDeleted("mandatory", EMPTY_NODE); }
@Test(expected = CommitFailedException.class) public void removeMandatoryChildNode() throws CommitFailedException { EffectiveType effective = createControl().createMock(EffectiveType.class); expect(effective.isMandatoryChildNode("mandatory")).andReturn(true); expect(effective.getDirectTypeNames()).andReturn(Collections.emptyList()); replay(effective); TypeEditor editor = new TypeEditor(effective); editor.childNodeDeleted("mandatory", EMPTY_NODE); }