use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler in project kie-wb-common by kiegroup.
the class ResourceUtilsTest method createNewResourceHandler.
private NewResourceHandler createNewResourceHandler(String description, int order) {
NewResourceHandler newResourceHandler = mock(NewResourceHandler.class);
doReturn(description).when(newResourceHandler).getDescription();
doReturn(order).when(newResourceHandler).order();
return newResourceHandler;
}
use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler in project kie-wb-common by kiegroup.
the class AddAssetScreenTest method mockResourceHandler.
private NewResourceHandler mockResourceHandler(Profile... profiles) {
NewResourceHandler nrh = mock(NewResourceHandler.class);
when(nrh.getProfiles()).thenReturn(Arrays.asList(profiles));
when(nrh.isProjectAsset()).thenReturn(true);
return nrh;
}
use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler in project kie-wb-common by kiegroup.
the class AddAssetScreenTest method testOnOpenProfileFilter.
@Test
public void testOnOpenProfileFilter() {
NewResourceHandler rhFull = mockResourceHandler(Profile.FULL);
NewResourceHandler rhDroolsPlanner = mockResourceHandler(Profile.PLANNER_AND_RULES);
NewResourceHandler rhAll = mockResourceHandler(Profile.values());
addAssetScreen.initialize();
doReturn(Arrays.asList(rhFull, rhDroolsPlanner, rhAll)).when(resourceHandlerManager).getNewResourceHandlers();
addAssetScreen.onOpen();
assertEquals(2, addAssetScreen.newResourceHandlers.size());
assertTrue(addAssetScreen.newResourceHandlers.contains(rhFull));
assertTrue(addAssetScreen.newResourceHandlers.contains(rhAll));
assertTrue(!addAssetScreen.newResourceHandlers.contains(rhDroolsPlanner));
executeParametrizedCommandWith(0, new ProfilePreferences(Profile.PLANNER_AND_RULES)).when(profilePreferences).load(any(ParameterizedCommand.class), any(ParameterizedCommand.class));
addAssetScreen.onOpen();
assertEquals(2, addAssetScreen.newResourceHandlers.size());
assertTrue(!addAssetScreen.newResourceHandlers.contains(rhFull));
assertTrue(addAssetScreen.newResourceHandlers.contains(rhAll));
assertTrue(addAssetScreen.newResourceHandlers.contains(rhDroolsPlanner));
}
use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler 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());
}
}
use of org.kie.workbench.common.widgets.client.handlers.NewResourceHandler in project kie-wb-common by kiegroup.
the class AddAssetScreenTest method testProfileFilter.
@Test
public void testProfileFilter() {
NewResourceHandler rhFull = mockResourceHandler(Profile.FULL);
NewResourceHandler rhDroolsPlanner = mockResourceHandler(Profile.PLANNER_AND_RULES);
NewResourceHandler rhAll = mockResourceHandler(Profile.values());
addAssetScreen.initialize();
doReturn(Arrays.asList(rhFull, rhDroolsPlanner, rhAll)).when(resourceHandlerManager).getNewResourceHandlers();
List<NewResourceHandler> filteredResourceHandlers = this.addAssetScreen.filterNewResourceHandlers(new ProfilePreferences(Profile.FULL));
assertEquals(2, filteredResourceHandlers.size());
filteredResourceHandlers = this.addAssetScreen.filterNewResourceHandlers(new ProfilePreferences(Profile.PLANNER_AND_RULES));
assertEquals(2, filteredResourceHandlers.size());
doReturn(Arrays.asList(rhFull, rhDroolsPlanner)).when(resourceHandlerManager).getNewResourceHandlers();
filteredResourceHandlers = this.addAssetScreen.filterNewResourceHandlers(new ProfilePreferences(Profile.PLANNER_AND_RULES));
assertEquals(1, filteredResourceHandlers.size());
assertEquals(Profile.PLANNER_AND_RULES, filteredResourceHandlers.get(0).getProfiles().get(0));
filteredResourceHandlers = this.addAssetScreen.filterNewResourceHandlers(new ProfilePreferences(Profile.FULL));
assertEquals(1, filteredResourceHandlers.size());
assertEquals(Profile.FULL, filteredResourceHandlers.get(0).getProfiles().get(0));
}
Aggregations