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);
}
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));
}
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());
}
}
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));
}
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());
}
Aggregations