### Question:
CaseManagementGraphFactoryImpl extends AbstractGraphFactory implements CaseManagementGraphFactory { @Override public Graph<DefinitionSet, Node> build(final String uuid, final String definitionSetId) { final Graph<DefinitionSet, Node> graph = super.build(uuid, definitionSetId); final List<Command> commands = buildInitialisationCommands(); final CompositeCommand.Builder commandBuilder = new CompositeCommand.Builder(); commands.forEach(commandBuilder::addCommand); graphCommandManager.execute(createGraphContext(graph), commandBuilder.build()); return graph; } protected  CaseManagementGraphFactoryImpl(); @Inject  CaseManagementGraphFactoryImpl(final DefinitionManager definitionManager,
                                          final FactoryManager factoryManager,
                                          final RuleManager ruleManager,
                                          final GraphCommandManager graphCommandManager,
                                          final GraphCommandFactory graphCommandFactory,
                                          final GraphIndexBuilder<?> indexBuilder,
                                          final BPMNGraphFactoryImpl graphFactory); @PostConstruct void init(); void setDiagramType(final Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(final String uuid, final String definitionSetId); @Override boolean accepts(final String source); static String START_EVENT_ID; static String SUBPROCESS_ID; static String END_EVENT_ID; static String SEQ_FLOW_ID; }### Answer:
@Test @SuppressWarnings("unchecked") public void testBuild() { final Node diagramNode = mock(Node.class); when(factoryManager.newElement(anyString(), eq(BindableAdapterUtils.getDefinitionId(CaseManagementDiagram.class)))).thenReturn(diagramNode); final Node stageNode = mock(Node.class); when(factoryManager.newElement(anyString(), eq(CaseManagementGraphFactoryImpl.SUBPROCESS_ID))).thenReturn(stageNode); when(stageNode.getContent()).thenReturn(mock(View.class)); final Node startEventNode = mock(Node.class); when(factoryManager.newElement(anyString(), eq(CaseManagementGraphFactoryImpl.START_EVENT_ID))).thenReturn(startEventNode); when(startEventNode.getContent()).thenReturn(mock(View.class)); final Node endEventNode = mock(Node.class); when(factoryManager.newElement(anyString(), eq(CaseManagementGraphFactoryImpl.END_EVENT_ID))).thenReturn(endEventNode); when(endEventNode.getContent()).thenReturn(mock(View.class)); final Edge startEventEdge = mock(Edge.class); final Edge endEventEdge = mock(Edge.class); when(factoryManager.newElement(anyString(), eq(CaseManagementGraphFactoryImpl.SEQ_FLOW_ID))).thenReturn(startEventEdge, endEventEdge); final Graph<DefinitionSet, Node> graph = factory.build("uuid1", "defSetId"); assertNotNull(graph); assertEquals("uuid1", graph.getUUID()); assertEquals(1, graph.getLabels().size()); assertTrue(graph.getLabels().contains("defSetId")); final ArgumentCaptor<Command> commandCaptor = ArgumentCaptor.forClass(Command.class); verify(graphCommandFactory, times(1)).addNode(eq(diagramNode)); verify(graphCommandManager, times(1)).execute(any(GraphCommandExecutionContext.class), commandCaptor.capture()); final Command command = commandCaptor.getValue(); assertTrue(command instanceof CompositeCommand); final CompositeCommand compositeCommand = (CompositeCommand) command; assertEquals(1, compositeCommand.size()); }