OpenMultipleMonitorsThisAction extends CompositeAction { @Override public boolean canHandle(ActionContext context) { actionContext = (ActionContextImpl) context; String targetDeviceNameID = actionContext.getTargetHousing().getHostedFrame().getGraphicsConfiguration().getDevice().getIDstring(); ArrayList<String> graphicsDeviceNames = DetectGraphicsDevices.getInstance().getGraphicDeviceNames(); List<Action> subActions = new ArrayList<Action>(graphicsDeviceNames.size()); for (String graphicsDeviceName : graphicsDeviceNames) { if (!graphicsDeviceName.equals(targetDeviceNameID)) { if (DetectGraphicsDevices.isMac() || DetectGraphicsDevices.isWindows()) { graphicsDeviceName = graphicsDeviceName.replace("\\Display", DetectGraphicsDevices.PROPER_DEVICE_NAME_PREFIX); } if (DetectGraphicsDevices.isUnixLinux() && graphicsDeviceName.contains(":0.")) { graphicsDeviceName = DetectGraphicsDevices.PROPER_DEVICE_NAME_PREFIX + graphicsDeviceName.replace(":0.", ""); } subActions.add(new SubMultipleMonitorsThisAction(graphicsDeviceName, actionContext)); } } setActions(subActions.toArray(new Action[subActions.size()])); return true; } OpenMultipleMonitorsThisAction(); @Override void actionPerformed(ActionEvent e); @Override boolean canHandle(ActionContext context); @Override boolean isEnabled();  }
@Test public void testCanHandle() { ActionContext context = mockActionContextObject(); Assert.assertTrue(context.getSelectedManifestations().size() == 1); Assert.assertNotNull(context); Mockito.when(manifestation.getManifestedComponent()).thenReturn(abstractComp); Assert.assertNotNull(abstractComp); }