Search in sources :

Example 61 with Path

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) EnumDropdownServiceImpl(org.kie.workbench.common.services.backend.enums.EnumDropdownServiceImpl) RawMVELEvaluator(org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator) EnumDropdownService(org.kie.workbench.common.services.shared.enums.EnumDropdownService) Test(org.junit.Test)

Example 62 with Path

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"));
}
Also used : Path(org.uberfire.backend.vfs.Path) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) Test(org.junit.Test)

Example 63 with Path

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"));
}
Also used : Path(org.uberfire.backend.vfs.Path) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) Test(org.junit.Test)

Example 64 with Path

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Example 65 with Path

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);
}
Also used : Path(org.uberfire.backend.vfs.Path) Metadata(org.guvnor.common.services.shared.metadata.model.Metadata) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Aggregations

Path (org.uberfire.backend.vfs.Path)136 Test (org.junit.Test)98 Metadata (org.guvnor.common.services.shared.metadata.model.Metadata)27 Package (org.guvnor.common.services.project.model.Package)23 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)20 FileAlreadyExistsException (org.uberfire.java.nio.file.FileAlreadyExistsException)19 ArrayList (java.util.ArrayList)13 NotificationEvent (org.uberfire.workbench.events.NotificationEvent)13 CommentedOption (org.uberfire.java.nio.base.options.CommentedOption)12 GuidedDecisionTableEditorGraphModel (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel)11 ValidationMessage (org.guvnor.common.services.shared.validation.model.ValidationMessage)10 NewResourceSuccessEvent (org.kie.workbench.common.widgets.client.handlers.NewResourceSuccessEvent)9 Mockito.anyString (org.mockito.Mockito.anyString)9 Overview (org.guvnor.common.services.shared.metadata.model.Overview)8 PackageDataModelOracle (org.kie.soup.project.datamodel.oracle.PackageDataModelOracle)8 ObservablePath (org.uberfire.backend.vfs.ObservablePath)8 List (java.util.List)7 GuidedDecisionTableEditorContent (org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorContent)7 HashMap (java.util.HashMap)6 HashSet (java.util.HashSet)6