### Question:
DMNToolboxControl extends AbstractToolboxControl { @Override protected List<ActionsToolboxFactory> getFactories() { if (readonlyProvider.isReadOnlyDiagram()) { return Collections.singletonList(commonActionsToolboxFactories.get()); } else { return Arrays.asList(flowActionsToolboxFactories.get(), commonActionsToolboxFactories.get()); } } @Inject  DMNToolboxControl(final @Any @DMNFlowActionsToolbox ManagedInstance<ActionsToolboxFactory> flowActionsToolboxFactories,
                             final @Any @DMNCommonActionsToolbox ManagedInstance<ActionsToolboxFactory> commonActionsToolboxFactories,
                             final @Any @DMNEditor ReadOnlyProvider readOnlyProvider); @PreDestroy @Override void destroy();  }### Answer:
@Test public void testRegisterTheRightFactories() { final List<ActionsToolboxFactory> factories = tested.getFactories(); assertNotNull(factories); assertEquals(2, factories.size()); assertEquals(flowActionsToolboxFactoryInstance, factories.get(0)); assertEquals(commonActionsToolboxFactoryInstance, factories.get(1)); }
@Test public void testGetFactoriesWhenIsReadOnlyDiagram() { when(readonlyProvider.isReadOnlyDiagram()).thenReturn(true); tested.getFactories(); verify(commonActionsToolboxFactory).get(); verify(flowActionsToolboxFactory, never()).get(); }
@Test public void testGetFactoriesWhenIsNotReadOnlyDiagram() { when(readonlyProvider.isReadOnlyDiagram()).thenReturn(false); tested.getFactories(); verify(commonActionsToolboxFactory).get(); verify(flowActionsToolboxFactory).get(); }