private void addProfileFullShortcuts(final HomeModel model) { model.addShortcut(createDesignShortcut()); model.addShortcut(createDeployShortcut()); model.addShortcut(createManageShortcut()); model.addShortcut(createTrackShortcut()); }
private void addProfileRulesPlannerShortcuts(final HomeModel model) { model.addShortcut(createDesignShortcut()); model.addShortcut(createDeployShortcut()); }
public HomeModel get(ProfilePreferences preferences) { this.profilePreferences = preferences; final HomeModel model = new HomeModel(translationService.format(Constants.Heading), translationService.format(Constants.SubHeading), "images/community_home_bg.jpg"); switch(profilePreferences.getProfile()) { case FULL: addProfileFullShortcuts(model); break; case PLANNER_AND_RULES: addProfileRulesPlannerShortcuts(model); break; default: addProfileFullShortcuts(model); break; } return model; }
@Test public void checkSetupWithProvisioningDenied() { when(shortcutHelper.authorize(PerspectiveIds.PROVISIONING)).thenReturn(false); final HomeModel model = producer.get(profilePreferences); assertNotNull(model); assertHomeModel(model, Constants.DeployDescription1); assertDesign(model); assertManage(model); assertTrack(model); assertEquals(1, model.getShortcuts().get(1).getLinks().size()); assertEquals(Constants.Servers, model.getShortcuts().get(1).getLinks().get(0).getLabel()); assertEquals(PerspectiveIds.SERVER_MANAGEMENT, model.getShortcuts().get(1).getLinks().get(0).getPerspectiveIdentifier()); }
@Test public void checkSetupWithProvisioningDenied() { when(shortcutHelper.authorize(PerspectiveIds.PROVISIONING)).thenReturn(false); final HomeModel model = producer.get(profilePreferences); assertHomeModel(model, Constants.DeployDescription1); assertDesign(model); assertEquals(1, model.getShortcuts().get(1).getLinks().size()); assertEquals(Constants.Servers, model.getShortcuts().get(1).getLinks().get(0).getLabel()); assertEquals(PerspectiveIds.SERVER_MANAGEMENT, model.getShortcuts().get(1).getLinks().get(0).getPerspectiveIdentifier()); }
@Before public void setup() { producer = new HomeProducer(placeManager, translationService, shortcutHelper); profilePreferences = new ProfilePreferences(Profile.PLANNER_AND_RULES); doAnswer((InvocationOnMock invocation) -> invocation.getArguments()[0]).when(translationService).format(anyString()); } @Test
@Override protected HomeShortcut createDesignShortcut() { final HomeShortcut design = ModelUtils.makeShortcut("pficon pficon-blueprint", translationService.format(Constants.Design), getDesignDescription(), () -> placeManager.goTo(LIBRARY), LIBRARY, PERSPECTIVE); design.addLink(new HomeShortcutLink(translationService.format(Constants.Projects), LIBRARY)); if (profilePreferences.getProfile() == Profile.FULL) { design.addLink(new HomeShortcutLink(translationService.format(Constants.Pages), CONTENT_MANAGEMENT)); } return design; }
protected HomeShortcut createDeployShortcut() { final HomeShortcutLink deployments = new HomeShortcutLink(translationService.format(Constants.Provisioning), PROVISIONING); final HomeShortcutLink servers = new HomeShortcutLink(translationService.format(Constants.Servers), SERVER_MANAGEMENT); final boolean isDeploymentsAuthorized = shortcutHelper.authorize(deployments.getPerspectiveIdentifier()); final HomeShortcut deploy = ModelUtils.makeShortcut("fa fa-gears", translationService.format(Constants.Deploy), getDeployDescription(isDeploymentsAuthorized), () -> placeManager.goTo(SERVER_MANAGEMENT), SERVER_MANAGEMENT, PERSPECTIVE); if (isDeploymentsAuthorized) { deploy.addLink(deployments); } deploy.addLink(servers); return deploy; }
@Test public void checkSetupWithProvisioningGranted() { when(shortcutHelper.authorize(PerspectiveIds.PROVISIONING)).thenReturn(true); final HomeModel model = producer.get(profilePreferences); assertHomeModel(model, Constants.DeployDescription2); assertDesign(model); assertManage(model); assertTrack(model); assertEquals(2, model.getShortcuts().get(1).getLinks().size()); assertEquals(Constants.Provisioning, model.getShortcuts().get(1).getLinks().get(0).getLabel()); assertEquals(PerspectiveIds.PROVISIONING, model.getShortcuts().get(1).getLinks().get(0).getPerspectiveIdentifier()); assertEquals(Constants.Servers, model.getShortcuts().get(1).getLinks().get(1).getLabel()); assertEquals(PerspectiveIds.SERVER_MANAGEMENT, model.getShortcuts().get(1).getLinks().get(1).getPerspectiveIdentifier()); }
@Test public void checkSetupWithProvisioningGranted() { when(shortcutHelper.authorize(PerspectiveIds.PROVISIONING)).thenReturn(true); final HomeModel model = producer.get(profilePreferences); assertHomeModel(model, Constants.DeployDescription2); assertDesign(model); assertEquals(2, model.getShortcuts().get(1).getLinks().size()); assertEquals(Constants.Provisioning, model.getShortcuts().get(1).getLinks().get(0).getLabel()); assertEquals(PerspectiveIds.PROVISIONING, model.getShortcuts().get(1).getLinks().get(0).getPerspectiveIdentifier()); assertEquals(Constants.Servers, model.getShortcuts().get(1).getLinks().get(1).getLabel()); assertEquals(PerspectiveIds.SERVER_MANAGEMENT, model.getShortcuts().get(1).getLinks().get(1).getPerspectiveIdentifier()); }
@Before public void setup() { producer = new HomeProducer(placeManager, translationService, shortcutHelper); profilePreferences = new ProfilePreferences(Profile.FULL); doAnswer((InvocationOnMock invocation) -> invocation.getArguments()[0]).when(translationService).format(anyString()); }