### Question:
ProjectDiagramServiceImpl extends KieService<ProjectDiagram> implements ProjectDiagramService { @Override public Path saveAsXml(final Path path, final String xml, final Metadata metadata, final String comment) { LOG.debug("Saving diagram as XML into path [" + path + "]."); return controller.saveAsXml(path, xml, metadataService.setUpAttributes(path, metadata), commentedOptionFactory.makeCommentedOption(comment)); } protected  ProjectDiagramServiceImpl(); @Inject  ProjectDiagramServiceImpl(final DefinitionManager definitionManager,
                                     final FactoryManager factoryManager,
                                     final Instance<DefinitionSetService> definitionSetServiceInstances,
                                     final BackendRegistryFactory registryFactory,
                                     final @Named("ioStrategy") IOService ioService,
                                     final SessionInfo sessionInfo,
                                     final Event<ResourceOpenedEvent> resourceOpenedEvent,
                                     final CommentedOptionFactory commentedOptionFactory,
                                     final KieModuleService moduleService,
                                     final KieServiceOverviewLoader overviewLoader,
                                     final User identity); @PostConstruct void init(); @Override ProjectDiagram getDiagramByPath(final Path path); @Override boolean accepts(final Path path); @Override Path create(final Path path,
                       final String name,
                       final String defSetId,
                       final String projectName,
                       final Package projectPkg,
                       final Optional<String> projectType); @Override Path create(final Path path,
                       final String name,
                       final String defSetId); @Override Path save(final Path path,
                     final ProjectDiagram content,
                     final Metadata metadata,
                     final String comment); @Override Path saveAsXml(final Path path,
                          final String xml,
                          final Metadata metadata,
                          final String comment); @Override ProjectMetadata saveOrUpdate(final ProjectDiagram diagram); @Override Path saveOrUpdateSvg(final Path diagramPath,
                                final String rawDiagramSvg); @Override boolean delete(final ProjectDiagram diagram); @Override void delete(final Path path,
                       final String comment); @Override String getRawContent(final ProjectDiagram diagram);  }### Answer:
@Test public void testSaveAsXml() { final String xml = "xml"; final String comment = "comment"; final Map<String, Object> attributes = Collections.singletonMap("key", "value"); final Path path = mock(Path.class); final Metadata metadata = mock(Metadata.class); final CommentedOption options = mock(CommentedOption.class); when(metadataService.setUpAttributes(path, metadata)).thenReturn(attributes); when(commentedOptionFactory.makeCommentedOption(comment)).thenReturn(options); diagramService.saveAsXml(path, xml, metadata, comment); verify(diagramServiceController, times(1)).saveAsXml(eq(path), eq(xml), eq(attributes), eq(options)); }