### Question:
BPMNDelegateGraphFactory implements BPMNGraphFactory { @Override public Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata) { final Optional<ProjectType> projectType = (Objects.nonNull(metadata) && metadata instanceof ProjectMetadata) ? Optional.ofNullable(((ProjectMetadata) metadata).getProjectType()).map(ProjectType::valueOf) : Optional.empty(); return graphFactoryDelegation.get(projectType).build(uuid, definition, metadata); } @Inject  BPMNDelegateGraphFactory(final BPMNGraphFactoryImpl bpmnGraphFactory,
                                    final CaseGraphFactoryImpl caseGraphFactory); @Override boolean isDelegateFactory(); @Override void setDiagramType(Class<? extends BPMNDiagram> diagramType); @Override Class<? extends ElementFactory> getFactoryType(); @Override Graph<DefinitionSet, Node> build(String uuid, String definition, Metadata metadata); @Override Graph<DefinitionSet, Node> build(String uuid, String definition); @Override boolean accepts(String source);  }### Answer:
@Test public void buildCase() { when(projectMetadata.getProjectType()).thenReturn(ProjectType.CASE.name()); tested.build(GRAPH_UUID, DEFINITION, projectMetadata); verify(caseGraphFactory).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); }
@Test public void buildBPMN() { when(projectMetadata.getProjectType()).thenReturn(ProjectType.BPMN.name()); tested.build(GRAPH_UUID, DEFINITION, projectMetadata); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, projectMetadata); }
@Test public void buildDefault() { tested.build(GRAPH_UUID, DEFINITION, projectMetadata); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, projectMetadata); tested.build(GRAPH_UUID, DEFINITION); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, null); final Metadata metadata = mock(Metadata.class); tested.build(GRAPH_UUID, DEFINITION, metadata); verify(caseGraphFactory, never()).build(GRAPH_UUID, DEFINITION, projectMetadata); verify(bpmnGraphFactory).build(GRAPH_UUID, DEFINITION, metadata); }
@Test public void build() { tested.build(GRAPH_UUID, DEFINITION); verify(tested).build(GRAPH_UUID, DEFINITION, null); }