### Question:
PMMLIncludedModelHandler implements DRGElementHandler { @Override public void destroy(final String oldModelName) { final List<Decision> decisions = getDecisions(); final List<BusinessKnowledgeModel> businessKnowledgeModels = getBusinessKnowledgeModels(); final List<FunctionDefinition> functions = getPMMLFunctionDefinitions(decisions, businessKnowledgeModels); final Map<FunctionDefinition, Context> contexts = getPMMLContexts(functions); final String quotedOldModelName = StringUtils.createQuotedString(oldModelName); for (final Map.Entry<FunctionDefinition, Context> entry : contexts.entrySet()) { final Context context = entry.getValue(); for (final ContextEntry contextEntry : context.getContextEntry()) { if (Objects.equals(LiteralExpressionPMMLDocument.VARIABLE_DOCUMENT, contextEntry.getVariable().getName().getValue())) { final Expression expression = contextEntry.getExpression(); if (expression instanceof IsLiteralExpression) { final IsLiteralExpression ile = (IsLiteralExpression) expression; if (Objects.nonNull(ile.getText())) { final Text text = ile.getText(); if (Objects.equals(quotedOldModelName, text.getValue())) { clearContextValues(context); entry.getKey().getFormalParameter().clear(); } } } } } } refreshCachedExpressionGrids(decisions, businessKnowledgeModels); } @Inject  PMMLIncludedModelHandler(final DMNGraphUtils dmnGraphUtils,
                                    final SessionManager sessionManager); @Override void update(final String oldModelName,
                       final String newModelName); @Override void destroy(final String oldModelName);  }### Answer:
@Test public void testDestroyDecisionWithTopLevelFunction() { final List<Decision> decisions = setupDecisionWithTopLevelFunction(); handler.destroy(DOCUMENT_NAME_ORIGINAL); assertTopLevelLiteralExpression(decisions.get(0)); assertTopLevelFunctionDefinition(decisions.get(1), "", ""); assertTopLevelFunctionDefinition(decisions.get(2), UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL); verify(expressionGrid1).initialiseUiCells(); verify(expressionGrid2).initialiseUiCells(); verify(expressionGrid3).initialiseUiCells(); }
@Test public void testDestroyDecisionWithNestedFunction() { final List<Decision> decisions = setupDecisionWithNestedFunction(); handler.destroy(DOCUMENT_NAME_ORIGINAL); assertNestedLiteralExpression(decisions.get(0)); assertNestedFunctionDefinition(decisions.get(1), "", ""); assertNestedFunctionDefinition(decisions.get(2), UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL); verify(expressionGrid1, never()).initialiseUiCells(); verify(expressionGrid2, never()).initialiseUiCells(); verify(expressionGrid3, never()).initialiseUiCells(); }
@Test public void testDestroyBusinessKnowledgeModelWithTopLevelFunction() { final List<BusinessKnowledgeModel> bkms = setupBusinessKnowledgeModelWithTopLevelFunction(); handler.destroy(DOCUMENT_NAME_ORIGINAL); assertTopLevelLiteralExpression(bkms.get(0)); assertPMMLContextDefinition(bkms.get(1).getEncapsulatedLogic(), "", ""); assertPMMLContextDefinition(bkms.get(2).getEncapsulatedLogic(), UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL); verify(expressionGrid1).initialiseUiCells(); verify(expressionGrid2).initialiseUiCells(); verify(expressionGrid3).initialiseUiCells(); }
@Test public void testDestroyBusinessKnowledgeModelWithNestedFunction() { final List<BusinessKnowledgeModel> bkms = setupBusinessKnowledgeModelWithNestedFunction(); handler.destroy(DOCUMENT_NAME_ORIGINAL); assertNestedLiteralExpression(bkms.get(0)); assertNestedFunctionDefinition(bkms.get(1), "", ""); assertNestedFunctionDefinition(bkms.get(2), UNAFFECTED_DOCUMENT, UNAFFECTED_MODEL); verify(expressionGrid1, never()).initialiseUiCells(); verify(expressionGrid2, never()).initialiseUiCells(); verify(expressionGrid3, never()).initialiseUiCells(); }