DefaultDeletionCheckStrategy implements IChildDeletionCheckStrategy { @Override public boolean checkDelete(final IObject creationContext, final IObject messageEnvironment) throws DeletionCheckException { try { IObject messageContext = (IObject) messageEnvironment.getValue(contextFN); Object deletionFlag = messageContext.getValue(deleteFN); messageContext.deleteField(deleteFN); return Boolean.TRUE == deletionFlag; } catch (ClassCastException | ReadValueException | DeleteValueException | InvalidArgumentException e) { throw new DeletionCheckException(e); } } DefaultDeletionCheckStrategy(); @Override boolean checkDelete(final IObject creationContext, final IObject messageEnvironment);  }
@Test public void Should_checkDeletionFlag() throws Exception { IChildDeletionCheckStrategy strategy = new DefaultDeletionCheckStrategy(); IObject ctx = IOC.resolve(Keys.getOrAdd(IObject.class.getCanonicalName())); IObject env = IOC.resolve(Keys.getOrAdd(IObject.class.getCanonicalName()), "{'context':{'deleteChild':true}}".replace('\'','"')); assertTrue(strategy.checkDelete(ctx, env)); env = IOC.resolve(Keys.getOrAdd(IObject.class.getCanonicalName()), "{'context':{'deleteChild':false}}".replace('\'','"')); assertFalse(strategy.checkDelete(ctx, env)); env = IOC.resolve(Keys.getOrAdd(IObject.class.getCanonicalName()), "{'context':{}}".replace('\'','"')); assertFalse(strategy.checkDelete(ctx, env)); }