Search in sources :

Example 81 with Path

use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorGraphDeleteHelperTest method checkRemoveReferencesWithoutDecisionTableGraphs.

@Test
public void checkRemoveReferencesWithoutDecisionTableGraphs() throws URISyntaxException {
    final org.uberfire.java.nio.file.Path dtPath = mock(org.uberfire.java.nio.file.Path.class);
    when(dtPath.getFileName()).thenReturn(mock(org.uberfire.java.nio.file.Path.class));
    when(dtPath.toUri()).thenReturn(new URI("default://test/dtable." + dtableType.getSuffix()));
    when(dtPath.getFileSystem()).thenReturn(fileSystem);
    paths.add(dtPath);
    when(path.getFileName()).thenReturn("dtable.gdst");
    when(path.toURI()).thenReturn("default://test/dtable.gdst");
    helper.postProcess(path);
    verify(helper, never()).updateGraphReferences(any(Path.class), any(Path.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) URI(java.net.URI) Test(org.junit.Test)

Example 82 with Path

use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImplCDITest method testUndeclaredFunction.

@Test
@Ignore("RHDM-329")
public void testUndeclaredFunction() throws Exception {
    final Path path = getPath("rhba370/src/main/resources/com/sample/dtissuesampleproject/UseUndeclaredFunction.gdst");
    final List<ValidationMessage> validationMessages = testedService.validate(path, testedService.load(path));
    Assertions.assertThat(validationMessages).hasSize(1);
    Assertions.assertThat(validationMessages).extracting("text", String.class).allMatch(text -> text.contains("[KBase: defaultKieBase]: Unable to Analyse Expression  isNotEmptyUndeclaredFunction(userCode)"));
}
Also used : Path(org.uberfire.backend.vfs.Path) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 83 with Path

use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImplCDITest method testFunctionFromDrl.

@Test
public void testFunctionFromDrl() throws Exception {
    final Path path = getPath("rhba370/src/main/resources/com/sample/dtissuesampleproject/UseFunctionFromDrl.gdst");
    final List<ValidationMessage> validationMessages = testedService.validate(path, testedService.load(path));
    Assertions.assertThat(validationMessages).isEmpty();
}
Also used : Path(org.uberfire.backend.vfs.Path) ValidationMessage(org.guvnor.common.services.shared.validation.model.ValidationMessage) Test(org.junit.Test)

Example 84 with Path

use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImplTest method checkCreate.

@Test
public void checkCreate() {
    final Path context = mock(Path.class);
    final String fileName = "filename." + dtType.getSuffix();
    final GuidedDecisionTable52 content = new GuidedDecisionTable52();
    final String comment = "comment";
    when(context.toURI()).thenReturn("default://project/src/main/resources/mypackage");
    final Path p = service.create(context, fileName, content, comment);
    verify(ioService, times(1)).write(any(org.uberfire.java.nio.file.Path.class), any(String.class), any(CommentedOption.class));
    assertTrue(p.toURI().contains("src/main/resources/mypackage/filename." + dtType.getSuffix()));
    assertEquals("mypackage", content.getPackageName());
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) CommentedOption(org.uberfire.java.nio.base.options.CommentedOption) Test(org.junit.Test)

Example 85 with Path

use of org.uberfire.backend.vfs.Path in project drools-wb by kiegroup.

the class GuidedDecisionTableEditorServiceImplTest method checkLoad.

@Test
public void checkLoad() {
    final Path path = mock(Path.class);
    when(path.toURI()).thenReturn("default://project/src/main/resources/mypackage/dtable.gdst");
    when(ioService.readAllString(any(org.uberfire.java.nio.file.Path.class))).thenReturn("");
    final GuidedDecisionTable52 model = service.load(path);
    verify(ioService, times(1)).readAllString(any(org.uberfire.java.nio.file.Path.class));
    assertNotNull(model);
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) 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