Search in sources :

Example 71 with Path

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

the class NewGuidedDecisionTableHandlerTest method testCreate_WithoutWizard.

@Test
public void testCreate_WithoutWizard() {
    final String fileName = "fileName";
    final Package pkg = mock(Package.class);
    final Path resourcesPath = PathFactory.newPath("resources", "default://project/src/main/resources");
    when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath);
    when(options.isUsingWizard()).thenReturn(false);
    handler.create(pkg, fileName, newResourcePresenter);
    verify(busyIndicatorView, times(1)).hideBusyIndicator();
    verify(newResourcePresenter, times(1)).complete();
    verify(mockNotificationEvent, times(1)).fire(any(NotificationEvent.class));
    verify(newResourceSuccessEventMock, times(1)).fire(any(NewResourceSuccessEvent.class));
    verify(placeManager, times(1)).goTo(pathCaptor.capture());
    assertEquals("default://project/src/main/resources/fileName.gdst", pathCaptor.getValue().toURI());
    verify(service, times(1)).create(eq(resourcesPath), eq(fileName + "." + resourceType.getSuffix()), any(GuidedDecisionTable52.class), any(String.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Package(org.guvnor.common.services.project.model.Package) NewResourceSuccessEvent(org.kie.workbench.common.widgets.client.handlers.NewResourceSuccessEvent) Test(org.junit.Test)

Example 72 with Path

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

the class NewGuidedDecisionTableHandlerTest method setup.

@Before
public void setup() {
    serviceCaller = new CallerMock<>(service);
    helper = new NewGuidedDecisionTableWizardHelper(serviceCaller, oracleFactory, beanManager);
    final NewGuidedDecisionTableHandler wrapped = new NewGuidedDecisionTableHandler(placeManager, serviceCaller, resourceType, options, busyIndicatorView, helper) {

        {
            this.notificationEvent = mockNotificationEvent;
            this.newResourceSuccessEvent = newResourceSuccessEventMock;
        }
    };
    handler = spy(wrapped);
    when(beanManager.lookupBean(eq(NewGuidedDecisionTableWizard.class))).thenReturn(wizardBeanDef);
    when(wizardBeanDef.getInstance()).thenReturn(wizardBean);
    when(service.create(any(Path.class), any(String.class), any(GuidedDecisionTable52.class), any(String.class))).<Path>thenAnswer((invocation) -> {
        final Path path = ((Path) invocation.getArguments()[0]);
        final String fileName = ((String) invocation.getArguments()[1]);
        final Path newPath = PathFactory.newPath(fileName, path.toURI() + "/" + fileName);
        return newPath;
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) NewGuidedDecisionTableWizardHelper(org.drools.workbench.screens.guided.dtable.client.wizard.NewGuidedDecisionTableWizardHelper) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) NewGuidedDecisionTableWizard(org.drools.workbench.screens.guided.dtable.client.wizard.table.NewGuidedDecisionTableWizard) Before(org.junit.Before)

Example 73 with Path

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

the class NewGuidedDecisionTableHandlerTest method testCreate_WithWizard.

@Test
public void testCreate_WithWizard() {
    final String fileName = "fileName";
    final Package pkg = mock(Package.class);
    final Path resourcesPath = PathFactory.newPath("resources", "default://project/src/main/resources");
    when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath);
    when(options.isUsingWizard()).thenReturn(true);
    when(options.getTableFormat()).thenReturn(TableFormat.EXTENDED_ENTRY);
    when(options.getHitPolicy()).thenReturn(GuidedDecisionTable52.HitPolicy.FIRST_HIT);
    handler.create(pkg, fileName, newResourcePresenter);
    verify(wizardBean, times(1)).setContent(pathCaptor.capture(), fileNameCaptor.capture(), eq(TableFormat.EXTENDED_ENTRY), eq(GuidedDecisionTable52.HitPolicy.FIRST_HIT), any(AsyncPackageDataModelOracle.class), any(NewGuidedDecisionTableWizard.GuidedDecisionTableWizardHandler.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) Package(org.guvnor.common.services.project.model.Package) Test(org.junit.Test)

Example 74 with Path

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

the class NewGuidedDecisionTableGraphHandlerTest method setup.

@Before
public void setup() {
    serviceCaller = new CallerMock<>(service);
    final NewGuidedDecisionTableGraphHandler wrapped = new NewGuidedDecisionTableGraphHandler(placeManager, serviceCaller, resourceType, busyIndicatorView) {

        {
            this.notificationEvent = mockNotificationEvent;
            this.newResourceSuccessEvent = newResourceSuccessEventMock;
        }
    };
    handler = spy(wrapped);
    when(service.create(any(Path.class), any(String.class), any(GuidedDecisionTableEditorGraphModel.class), any(String.class))).<Path>thenAnswer((invocation) -> {
        final Path path = ((Path) invocation.getArguments()[0]);
        final String fileName = ((String) invocation.getArguments()[1]);
        final Path newPath = PathFactory.newPath(fileName, path.toURI() + "/" + fileName);
        return newPath;
    });
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) Before(org.junit.Before)

Example 75 with Path

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

the class NewGuidedDecisionTableGraphHandlerTest method testCreate.

@Test
public void testCreate() {
    final String fileName = "fileName";
    final Package pkg = mock(Package.class);
    final Path resourcesPath = PathFactory.newPath("resources", "default://project/src/main/resources");
    when(pkg.getPackageMainResourcesPath()).thenReturn(resourcesPath);
    handler.create(pkg, fileName, newResourcePresenter);
    verify(busyIndicatorView, times(1)).hideBusyIndicator();
    verify(newResourcePresenter, times(1)).complete();
    verify(mockNotificationEvent, times(1)).fire(any(NotificationEvent.class));
    verify(newResourceSuccessEventMock, times(1)).fire(any(NewResourceSuccessEvent.class));
    verify(placeManager, times(1)).goTo(pathCaptor.capture());
    assertEquals("default://project/src/main/resources/fileName." + resourceType.getSuffix(), pathCaptor.getValue().toURI());
    verify(service, times(1)).create(eq(resourcesPath), eq(fileName + "." + resourceType.getSuffix()), any(GuidedDecisionTableEditorGraphModel.class), any(String.class));
}
Also used : Path(org.uberfire.backend.vfs.Path) GuidedDecisionTableEditorGraphModel(org.drools.workbench.screens.guided.dtable.model.GuidedDecisionTableEditorGraphModel) NotificationEvent(org.uberfire.workbench.events.NotificationEvent) Package(org.guvnor.common.services.project.model.Package) NewResourceSuccessEvent(org.kie.workbench.common.widgets.client.handlers.NewResourceSuccessEvent) 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