### Question:
DMNCommonActionsToolboxFactory extends CommonActionsToolboxFactory { void addEditAction(final Element<?> element, final List<ToolboxAction<AbstractCanvasHandler>> actions) { if (isDecision(element)) { actions.add(editDecisionToolboxActions.get()); } else if (isBusinessKnowledgeModel(element)) { actions.add(editBusinessKnowledgeModelToolboxActions.get()); } } @Inject  DMNCommonActionsToolboxFactory(final @Any ManagedInstance<DMNEditDecisionToolboxAction> editDecisionToolboxActions,
                                          final @Any ManagedInstance<DMNEditBusinessKnowledgeModelToolboxAction> editBusinessKnowledgeModelToolboxActions,
                                          final @Any ManagedInstance<DMNEditDRDToolboxAction> editDRDToolboxActions,
                                          final @Any @CommonActionsToolbox ManagedInstance<ActionsToolboxView> views,
                                          final CanvasCommandManager<AbstractCanvasHandler> commandManager,
                                          final @DMNEditor DefaultCanvasCommandFactory commandFactory,
                                          final @DMNEditor ManagedInstance<DeleteNodeToolboxAction> deleteNodeActions,
                                          final @DMNEditor ReadOnlyProvider readOnlyProvider); @Override @SuppressWarnings("unchecked") Collection<ToolboxAction<AbstractCanvasHandler>> getActions(final AbstractCanvasHandler canvasHandler,
                                                                       final Element<?> element); @PreDestroy void destroy();  }### Answer:
@Test public void testAddEditDecisionAction() { final List<ToolboxAction<AbstractCanvasHandler>> actions = new ArrayList<>(); final Element element = mock(Element.class); final Node node = mock(Node.class); final Definition definition = mock(Definition.class); final Decision decision = mock(Decision.class); when(element.asNode()).thenReturn(node); when(element.getContent()).thenReturn(definition); when(definition.getDefinition()).thenReturn(decision); tested.addEditAction(element, actions); assertEquals(1, actions.size()); assertTrue(DMNEditDecisionToolboxAction.class.isInstance(actions.get(0))); }
@Test public void testAddEditBusinessKnowledgeModelAction() { final List<ToolboxAction<AbstractCanvasHandler>> actions = new ArrayList<>(); final Element element = mock(Element.class); final Node node = mock(Node.class); final Definition definition = mock(Definition.class); final BusinessKnowledgeModel bkm = mock(BusinessKnowledgeModel.class); when(element.asNode()).thenReturn(node); when(element.getContent()).thenReturn(definition); when(definition.getDefinition()).thenReturn(bkm); tested.addEditAction(element, actions); assertEquals(1, actions.size()); assertTrue(DMNEditBusinessKnowledgeModelToolboxAction.class.isInstance(actions.get(0))); }
@Test public void testAddEditWhenIsNotDecisionOrBusinessKnowledgeModelAction() { final List<ToolboxAction<AbstractCanvasHandler>> actions = new ArrayList<>(); final Element element = mock(Element.class); final Node node = mock(Node.class); final Definition definition = mock(Definition.class); final Object someObject = mock(Object.class); when(element.asNode()).thenReturn(node); when(element.getContent()).thenReturn(definition); when(definition.getDefinition()).thenReturn(someObject); tested.addEditAction(element, actions); assertEquals(0, actions.size()); }