@Test
public void testSave() {
getExpectedContent().getDef().setName(getOriginalDef().getName());
String originalSource = getOriginalDefString();
when(path.toURI()).thenReturn(FILE_URI);
org.uberfire.java.nio.file.Path targetNioPath = Paths.convert(path);
when(ioService.readAllString(targetNioPath)).thenReturn(originalSource);
when(moduleService.resolveModule(path)).thenReturn(module);
editorService.save(path,
getExpectedContent(),
COMMENT);
verify(defRegistry,
times(1)).invalidateCache(path);
verify(ioService,
times(1)).write(eq(targetNioPath),
eq(getExpectedDefString()),
any(CommentedOption.class));
verify(optionsFactory,
times(1)).makeCommentedOption(COMMENT);
verify(defRegistry,
times(1)).setEntry(path,
getExpectedDef());
verifySaveConditions();
}