Search in sources :

Example 6 with NewResourceHandler

use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler in project kie-wb-common by kiegroup.

the class AssetsActionsWidgetTest method initTest.

@Test
public void initTest() {
    NewResourceHandler packageHandler = mock(NewPackageHandler.class);
    doReturn(true).when(packageHandler).canCreate();
    NewResourceHandler type1Handler = mock(NewResourceHandler.class);
    doReturn(true).when(type1Handler).canCreate();
    NewResourceHandler type2Handler = mock(NewResourceHandler.class);
    doReturn(true).when(type2Handler).canCreate();
    List<NewResourceHandler> handlers = new ArrayList<>();
    handlers.add(packageHandler);
    handlers.add(type1Handler);
    handlers.add(type2Handler);
    doReturn(handlers).when(resourceUtils).getAlphabeticallyOrderedNewResourceHandlers();
    presenter.init();
    verify(view, times(3)).addResourceHandler(any(NewResourceHandler.class));
    verify(view).addResourceHandler(packageHandler);
    verify(view).addResourceHandler(type1Handler);
    verify(view).addResourceHandler(type2Handler);
}
Also used : NewResourceHandler(org.kie.workbench.common.widgets.client.handlers.NewResourceHandler) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 7 with NewResourceHandler

use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler in project kie-wb-common by kiegroup.

the class AddAssetScreenTest method testOnOpen.

@Test
public void testOnOpen() {
    NewResourceHandler rh1 = new NewFileUploader();
    NewResourceHandler rh2 = new NewJavaFileTextHandler();
    doReturn(Arrays.asList(rh1, rh2)).when(resourceHandlerManager).getNewResourceHandlers();
    addAssetScreen.initialize();
    addAssetScreen.onOpen();
    assertEquals(1, addAssetScreen.newResourceHandlers.size());
    assertEquals(rh2, addAssetScreen.newResourceHandlers.get(0));
}
Also used : NewResourceHandler(org.kie.workbench.common.widgets.client.handlers.NewResourceHandler) NewFileUploader(org.kie.workbench.common.screens.defaulteditor.client.editor.NewFileUploader) NewJavaFileTextHandler(org.kie.workbench.common.screens.datamodeller.client.handlers.NewJavaFileTextHandler) Test(org.junit.Test)

Example 8 with NewResourceHandler

use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler 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 9 with NewResourceHandler

use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler in project kie-wb-common by kiegroup.

the class ResourceHandlerManagerTest method testResourceHandlers.

@Test
public void testResourceHandlers() {
    NewResourceHandler rh1 = mock(NewResourceHandler.class);
    NewResourceHandler rh2 = mock(NewResourceHandler.class);
    when(rh1.getResourceType()).thenReturn(new JavaResourceTypeDefinition(new Model()));
    when(rh2.getResourceType()).thenReturn(new ProjectImportsResourceTypeDefinition(new Others()));
    doReturn(Arrays.asList(rh1, rh2)).when(this.resourceHandlerManager).getNewResourceHandlers();
    List<NewResourceHandler> handlers = this.resourceHandlerManager.getNewResourceHandlers(resourceHandler -> resourceHandler.getResourceType().getCategory().equals(new Model()));
    assertTrue(handlers.size() == 1);
    assertEquals(rh1, handlers.get(0));
}
Also used : NewResourceHandler(org.kie.workbench.common.widgets.client.handlers.NewResourceHandler) Others(org.uberfire.workbench.category.Others) ProjectImportsResourceTypeDefinition(org.kie.workbench.common.screens.projectimportsscreen.type.ProjectImportsResourceTypeDefinition) Model(org.guvnor.common.services.project.categories.Model) JavaResourceTypeDefinition(org.kie.workbench.common.screens.javaeditor.type.JavaResourceTypeDefinition) Test(org.junit.Test)

Example 10 with NewResourceHandler

use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler in project kie-wb-common by kiegroup.

the class AddProjectButtonPresenterTest method initTest.

@Test
public void initTest() {
    NewWorkspaceProjectHandler otherNewWorkspaceProjectHandler1 = mock(NewWorkspaceProjectHandler.class);
    doReturn(true).when(otherNewWorkspaceProjectHandler1).canCreate();
    NewWorkspaceProjectHandler otherNewWorkspaceProjectHandler2 = mock(NewWorkspaceProjectHandler.class);
    doReturn(false).when(otherNewWorkspaceProjectHandler2).canCreate();
    List<NewResourceHandler> handlers = new ArrayList<>();
    handlers.add(otherNewWorkspaceProjectHandler1);
    handlers.add(otherNewWorkspaceProjectHandler2);
    doReturn(handlers).when(presenter).getNewProjectHandlers();
    presenter.init();
    verify(view, never()).hideOtherProjects();
    verify(presenter).addNewProjectHandler(otherNewWorkspaceProjectHandler1);
    verify(view).addOtherProject(any());
}
Also used : NewResourceHandler(org.kie.workbench.common.widgets.client.handlers.NewResourceHandler) ArrayList(java.util.ArrayList) NewWorkspaceProjectHandler(org.kie.workbench.common.widgets.client.handlers.NewWorkspaceProjectHandler) Test(org.junit.Test)

Aggregations

NewResourceHandler (org.kie.workbench.common.widgets.client.handlers.NewResourceHandler)10 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Decision (org.guvnor.common.services.project.categories.Decision)2 ProfilePreferences (org.kie.workbench.common.profile.api.preferences.ProfilePreferences)2 Others (org.uberfire.workbench.category.Others)2 Model (org.guvnor.common.services.project.categories.Model)1 NewJavaFileTextHandler (org.kie.workbench.common.screens.datamodeller.client.handlers.NewJavaFileTextHandler)1 NewFileUploader (org.kie.workbench.common.screens.defaulteditor.client.editor.NewFileUploader)1 JavaResourceTypeDefinition (org.kie.workbench.common.screens.javaeditor.type.JavaResourceTypeDefinition)1 ProjectImportsResourceTypeDefinition (org.kie.workbench.common.screens.projectimportsscreen.type.ProjectImportsResourceTypeDefinition)1 NewWorkspaceProjectHandler (org.kie.workbench.common.widgets.client.handlers.NewWorkspaceProjectHandler)1 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)1 Undefined (org.uberfire.workbench.category.Undefined)1