NewGuidedDecisionTreeHandler extends DefaultNewResourceHandler { @Override public boolean canCreate() { return authorizationManager.authorize(new ResourceRef(EditorIds.GUIDED_DECISION_TREE, ActivityResourceType.EDITOR), ResourceAction.READ, sessionInfo.getIdentity()); } NewGuidedDecisionTreeHandler(); @Inject  NewGuidedDecisionTreeHandler(final Caller<GuidedDecisionTreeEditorService> service,
                                        final GuidedDTreeResourceType resourceType,
                                        final BusyIndicatorView busyIndicatorView,
                                        final AuthorizationManager authorizationManager,
                                        final SessionInfo sessionInfo); @Override String getDescription(); @Override IsWidget getIcon(); @Override ResourceTypeDefinition getResourceType(); @Override boolean canCreate(); @Override void create(final Package pkg,
                       final String baseFileName,
                       final NewResourcePresenter presenter);  }
@Test public void checkCanCreateWhenFeatureDisabled() { when(authorizationManager.authorize(any(ResourceRef.class), eq(ResourceAction.READ), eq(user))).thenReturn(false); assertFalse(handler.canCreate()); assertResourceRef(); }
@Test public void checkCanCreateWhenFeatureEnabled() { when(authorizationManager.authorize(any(ResourceRef.class), eq(ResourceAction.READ), eq(user))).thenReturn(true); assertTrue(handler.canCreate()); assertResourceRef(); }