use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class EnumDropDownServiceTest method testLoadDropDownNoValuePairs.
@Test
public void testLoadDropDownNoValuePairs() throws Exception {
// Override code that converts Path to ClassLoader for test
final ClassLoader cl = Thread.currentThread().getContextClassLoader();
final EnumDropdownService service = new EnumDropdownServiceImpl() {
@Override
public String[] loadDropDownExpression(final Path resource, final String[] valuePairs, final String expression) {
return super.loadDropDownExpression(cl, new RawMVELEvaluator(), valuePairs, expression);
}
};
final String[] pairs = new String[] { null };
final String expression = "['@{f1}', '@{f2}']";
final String[] r = service.loadDropDownExpression(mock(Path.class), pairs, expression);
assertEquals(0, r.length);
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleEditorCopyHelperTest method testRDRLFile.
@Test
public void testRDRLFile() {
final Path pathSource = mock(Path.class);
final Path pathDestination = mock(Path.class);
when(pathSource.toURI()).thenReturn("default://p0/src/main/resources/MyFile.rdrl");
when(pathDestination.toURI()).thenReturn("default://p0/src/main/resources/MyNewFile.rdrl");
when(pathDestination.getFileName()).thenReturn("MyNewFile.rdrl");
when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn(drl);
helper.postProcess(pathSource, pathDestination);
final ArgumentCaptor<String> drlArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), drlArgumentCaptor.capture(), any(CommentedOption.class));
final String newDrl = drlArgumentCaptor.getValue();
assertNotNull(newDrl);
assertTrue(newDrl.contains("MyNewFile"));
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleEditorCopyHelperTest method testRDSLRFile.
@Test
public void testRDSLRFile() {
final Path pathSource = mock(Path.class);
final Path pathDestination = mock(Path.class);
when(pathSource.toURI()).thenReturn("default://p0/src/main/resources/MyFile.rdslr");
when(pathDestination.toURI()).thenReturn("default://p0/src/main/resources/MyNewFile.rdslr");
when(pathDestination.getFileName()).thenReturn("MyNewFile.rdslr");
when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn(dslr);
helper.postProcess(pathSource, pathDestination);
final ArgumentCaptor<String> drlArgumentCaptor = ArgumentCaptor.forClass(String.class);
verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), drlArgumentCaptor.capture(), any(CommentedOption.class));
final String newDrl = drlArgumentCaptor.getValue();
assertNotNull(newDrl);
assertTrue(newDrl.contains("MyNewFile"));
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleEditorServiceImplTest method testLoadModifyScoreAction.
@Test
public void testLoadModifyScoreAction() throws Exception {
final Path path = getPath("modifyScore.rdrl");
final String ruleFileContent = getFileContent("modifyScore.rdrl");
doReturn(ruleFileContent).when(ioService).readAllString(any());
final RuleModel model = service.load(path);
Assertions.assertThat(model.rhs).hasSize(1);
final FreeFormLine action = (FreeFormLine) model.rhs[0];
Assertions.assertThat(action.getText()).isEqualTo(MODIFY_SCORE_ACTION);
}
use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.
the class GuidedRuleEditorServiceImplTest method testSaveAndRename.
@Test
public void testSaveAndRename() throws Exception {
final Path path = mock(Path.class);
final String newFileName = "newFileName";
final Metadata metadata = mock(Metadata.class);
final RuleModel content = mock(RuleModel.class);
final String comment = "comment";
service.saveAndRename(path, newFileName, metadata, content, comment);
verify(saveAndRenameService).saveAndRename(path, newFileName, metadata, content, comment);
}
Aggregations