Search in sources :

Example 1 with Decision

use of org.guvnor.common.services.project.categories.Decision in project kie-wb-common by kiegroup.

the class AddAssetScreenTest method testFilterByCategory.

@Test
public void testFilterByCategory() {
    NewResourceHandler resourceHandler = mock(NewResourceHandler.class, Answers.RETURNS_DEEP_STUBS.get());
    when(resourceHandler.getDescription()).thenReturn("demo");
    when(resourceHandler.getResourceType().getCategory()).thenReturn(new Decision());
    {
        List<NewResourceHandler> filtered = this.addAssetScreen.filterAndSortHandlers(Arrays.asList(resourceHandler), "", new Decision());
        assertEquals(resourceHandler, filtered.get(0));
    }
    {
        List<NewResourceHandler> filtered = this.addAssetScreen.filterAndSortHandlers(Arrays.asList(resourceHandler), "", new Others());
        assertTrue(filtered.isEmpty());
    }
}
Also used : NewResourceHandler(org.kie.workbench.common.widgets.client.handlers.NewResourceHandler) Others(org.uberfire.workbench.category.Others) List(java.util.List) Decision(org.guvnor.common.services.project.categories.Decision) Test(org.junit.Test)

Example 2 with Decision

use of org.guvnor.common.services.project.categories.Decision in project drools-wb by kiegroup.

the class ScenarioEditorPresenterTest method setUp.

@Before
public void setUp() throws Exception {
    promises = new SyncPromises();
    final AsyncPackageDataModelOracleFactory modelOracleFactory = mock(AsyncPackageDataModelOracleFactory.class);
    fakeService = new CallerMock<>(service);
    editor = spy(new ScenarioEditorPresenter(view, user, importsWidget, fakeService, new TestScenarioResourceType(new Decision()), modelOracleFactory, settingsPage, auditPage, testRunnerReportingPanel, testReportingDocksHandler, showTestPanelEvent, hideTestPanelEvent) {

        {
            docks = ScenarioEditorPresenterTest.this.docks;
            kieView = ScenarioEditorPresenterTest.this.kieView;
            versionRecordManager = ScenarioEditorPresenterTest.this.versionRecordManager;
            overviewWidget = ScenarioEditorPresenterTest.this.overviewWidget;
            notification = ScenarioEditorPresenterTest.this.notificationEventMock;
            fileMenuBuilder = ScenarioEditorPresenterTest.this.fileMenuBuilder;
            projectController = ScenarioEditorPresenterTest.this.projectController;
            workbenchContext = ScenarioEditorPresenterTest.this.workbenchContext;
            versionRecordManager = ScenarioEditorPresenterTest.this.versionRecordManager;
            alertsButtonMenuItemBuilder = ScenarioEditorPresenterTest.this.alertsButtonMenuItemBuilder;
            perspectiveManager = ScenarioEditorPresenterTest.this.perspectiveManager;
            placeManager = ScenarioEditorPresenterTest.this.placeManager;
            promises = ScenarioEditorPresenterTest.this.promises;
        }

        @Override
        protected Command getSaveAndRename() {
            return mock(Command.class);
        }
    });
    doNothing().when(editor).addDownloadMenuItem(any());
    scenarioRunResult = new Scenario();
    scenario = new Scenario();
    overview = new Overview();
    when(user.getIdentifier()).thenReturn("userName");
    when(workbenchContext.getActiveOrganizationalUnit()).thenReturn(Optional.empty());
    when(workbenchContext.getActiveWorkspaceProject()).thenReturn(Optional.empty());
    final TestScenarioModelContent testScenarioModelContent = new TestScenarioModelContent(scenario, overview, "org.test", new PackageDataModelOracleBaselinePayload());
    when(service.loadContent(any())).thenReturn(testScenarioModelContent);
    final TestScenarioResult result = new TestScenarioResult(scenarioRunResult, Collections.EMPTY_SET, mock(TestResultMessage.class));
    when(service.runScenario(eq("userName"), any(), eq(scenario))).thenReturn(result);
    final AsyncPackageDataModelOracle dmo = mock(AsyncPackageDataModelOracle.class);
    when(modelOracleFactory.makeAsyncPackageDataModelOracle(any(), any(), any())).thenReturn(dmo);
    when(alertsButtonMenuItemBuilder.build()).thenReturn(alertsButtonMenuItem);
    when(perspectiveManager.getCurrentPerspective()).thenReturn(mock(PerspectiveActivity.class));
}
Also used : AsyncPackageDataModelOracle(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle) PerspectiveActivity(org.uberfire.client.mvp.PerspectiveActivity) SyncPromises(org.uberfire.promise.SyncPromises) TestScenarioModelContent(org.drools.workbench.screens.testscenario.model.TestScenarioModelContent) TestResultMessage(org.guvnor.common.services.shared.test.TestResultMessage) TestScenarioResourceType(org.drools.workbench.screens.testscenario.client.type.TestScenarioResourceType) Overview(org.guvnor.common.services.shared.metadata.model.Overview) TestScenarioResult(org.drools.workbench.screens.testscenario.model.TestScenarioResult) Decision(org.guvnor.common.services.project.categories.Decision) Scenario(org.drools.workbench.models.testscenarios.shared.Scenario) AsyncPackageDataModelOracleFactory(org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracleFactory) PackageDataModelOracleBaselinePayload(org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload) Before(org.junit.Before)

Example 3 with Decision

use of org.guvnor.common.services.project.categories.Decision in project kie-wb-common by kiegroup.

the class DMNDiagramResourceTypeTest method setup.

@Before
public void setup() {
    final Decision category = new Decision();
    this.definitionSetResourceType = new DMNDefinitionSetResourceType(category);
    this.resourceType = new DMNDiagramResourceType(category, translationService);
    doAnswer((i) -> i.getArguments()[0].toString()).when(translationService).getTranslation(Mockito.<String>any());
}
Also used : Decision(org.guvnor.common.services.project.categories.Decision) DMNDefinitionSetResourceType(org.kie.workbench.common.dmn.api.resource.DMNDefinitionSetResourceType) Before(org.junit.Before)

Example 4 with Decision

use of org.guvnor.common.services.project.categories.Decision in project kie-wb-common by kiegroup.

the class AddAssetScreenTest method testFilterByName.

@Test
public void testFilterByName() {
    NewResourceHandler resourceHandler = mock(NewResourceHandler.class, Answers.RETURNS_DEEP_STUBS.get());
    when(resourceHandler.getDescription()).thenReturn("demo");
    when(resourceHandler.getResourceType().getCategory()).thenReturn(new Decision());
    {
        List<NewResourceHandler> filtered = this.addAssetScreen.filterAndSortHandlers(Arrays.asList(resourceHandler), "de", new Undefined());
        assertEquals(resourceHandler, filtered.get(0));
    }
    {
        List<NewResourceHandler> filtered = this.addAssetScreen.filterAndSortHandlers(Arrays.asList(resourceHandler), "ja", new Undefined());
        assertTrue(filtered.isEmpty());
    }
}
Also used : NewResourceHandler(org.kie.workbench.common.widgets.client.handlers.NewResourceHandler) Undefined(org.uberfire.workbench.category.Undefined) List(java.util.List) Decision(org.guvnor.common.services.project.categories.Decision) Test(org.junit.Test)

Example 5 with Decision

use of org.guvnor.common.services.project.categories.Decision in project kie-wb-common by kiegroup.

the class CategoryUtilsTest method testCreateCategories.

@Test
public void testCreateCategories() {
    when(this.categoriesManagerCache.getCategories()).thenReturn(new HashSet<>(Arrays.asList(new Others(), new Decision())));
    List<SelectOption> categories = this.categoryUtils.createCategories();
    assertEquals(3, categories.size());
    assertTrue(categories.stream().anyMatch(selectOption -> selectOption.getSelector().equals("ALL")));
    assertTrue(categories.stream().anyMatch(selectOption -> selectOption.getSelector().equals(new Others().getName())));
    assertTrue(categories.stream().anyMatch(selectOption -> selectOption.getSelector().equals(new Decision().getName())));
}
Also used : Arrays(java.util.Arrays) TranslationService(org.jboss.errai.ui.client.local.spi.TranslationService) SelectOptionImpl(org.uberfire.ext.widgets.common.client.select.SelectOptionImpl) Mock(org.mockito.Mock) RunWith(org.junit.runner.RunWith) Test(org.junit.Test) SelectOption(org.uberfire.ext.widgets.common.client.select.SelectOption) HashSet(java.util.HashSet) Mockito(org.mockito.Mockito) List(java.util.List) CategoriesManagerCache(org.uberfire.client.mvp.CategoriesManagerCache) Others(org.uberfire.workbench.category.Others) Decision(org.guvnor.common.services.project.categories.Decision) Assert(org.junit.Assert) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Before(org.junit.Before) Others(org.uberfire.workbench.category.Others) SelectOption(org.uberfire.ext.widgets.common.client.select.SelectOption) Decision(org.guvnor.common.services.project.categories.Decision) Test(org.junit.Test)

Aggregations

Decision (org.guvnor.common.services.project.categories.Decision)5 List (java.util.List)3 Before (org.junit.Before)3 Test (org.junit.Test)3 NewResourceHandler (org.kie.workbench.common.widgets.client.handlers.NewResourceHandler)2 Others (org.uberfire.workbench.category.Others)2 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 Scenario (org.drools.workbench.models.testscenarios.shared.Scenario)1 TestScenarioResourceType (org.drools.workbench.screens.testscenario.client.type.TestScenarioResourceType)1 TestScenarioModelContent (org.drools.workbench.screens.testscenario.model.TestScenarioModelContent)1 TestScenarioResult (org.drools.workbench.screens.testscenario.model.TestScenarioResult)1 Overview (org.guvnor.common.services.shared.metadata.model.Overview)1 TestResultMessage (org.guvnor.common.services.shared.test.TestResultMessage)1 TranslationService (org.jboss.errai.ui.client.local.spi.TranslationService)1 Assert (org.junit.Assert)1 RunWith (org.junit.runner.RunWith)1 DMNDefinitionSetResourceType (org.kie.workbench.common.dmn.api.resource.DMNDefinitionSetResourceType)1 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)1 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)1