### Question:
FormEditorServiceImpl extends KieService<FormModelerContent> implements FormEditorService { @Override public Path createForm(Path path, String formName, FormModel formModel) { org.uberfire.java.nio.file.Path kiePath = Paths.convert(path).resolve(formName); try { if (ioService.exists(kiePath)) { throw new FileAlreadyExistsException(kiePath.toString()); } FormDefinition form = new FormDefinition(formModel); form.setId(UIDGenerator.generateUID()); form.setName(formName.substring(0, formName.lastIndexOf("."))); form.setLayoutTemplate(new LayoutTemplate()); ioService.write(kiePath, formDefinitionSerializer.serialize(form), commentedOptionFactory.makeCommentedOption("")); return Paths.convert(kiePath); } catch (Exception e) { throw ExceptionUtilities.handleException(e); } } @Inject  FormEditorServiceImpl(@Named("ioStrategy") IOService ioService,
                                 SessionInfo sessionInfo,
                                 Event<ResourceOpenedEvent> resourceOpenedEvent,
                                 FieldManager fieldManager,
                                 FormModelHandlerManager modelHandlerManager,
                                 KieModuleService moduleService,
                                 FormDefinitionSerializer formDefinitionSerializer,
                                 ModuleFormFinderService moduleFormFinderService,
                                 DeleteService deleteService,
                                 CommentedOptionFactory commentedOptionFactory,
                                 RenameService renameService,
                                 CopyService copyService); @Override FormModelerContent loadContent(Path path); @Override Path createForm(Path path,
                           String formName,
                           FormModel formModel); @Override void delete(Path path,
                       String comment); @Override Path save(Path path,
                     FormModelerContent content,
                     Metadata metadata,
                     String comment); @Override FormModelerContent rename(Path path,
                                     String newFileName,
                                     String commitMessage,
                                     boolean saveBeforeRenaming,
                                     FormModelerContent content,
                                     Metadata metadata); @Override void copy(Path path,
                     String newFileName,
                     String commitMessage,
                     boolean saveBeforeCopying,
                     FormModelerContent content,
                     Metadata metadata); static final String SHORT_KEY; static final String LONG_KEY; }### Answer:
@Test public void testCreateForm() { when(formDefinitionSerializer.serialize(any())).thenAnswer(this::verifyNewForm); FormModel formModel = mock(FormModel.class); Path resultPath = formEditorService.createForm(path, FULL_FORM_NAME, formModel); assertNotNull(resultPath); }
@Test public void testCreateFormThatExistsOnVFS() { try { when(ioService.exists(any())).thenReturn(true); FormModel formModel = mock(FormModel.class); formEditorService.createForm(path, FULL_FORM_NAME, formModel); fail("If form exists we shouldn't be here"); } catch (FileAlreadyExistsException ex) { } }