@Test public void testCanHandle() { ActionContext mockContext = Mockito.mock(ActionContext.class); View mockView = Mockito.mock(View.class); AbstractComponent mockComponent = Mockito.mock(AbstractComponent.class); Mockito.when(mockView.getManifestedComponent()).thenReturn(mockComponent); Mockito.when(mockContext.getWindowManifestation()).thenReturn(null); Assert.assertFalse(importThisAction.canHandle(mockContext)); Mockito.when(mockContext.getWindowManifestation()).thenReturn(mockView); Assert.assertTrue(importThisAction.canHandle(mockContext)); Mockito.when(mockContext.getSelectedManifestations()) .thenReturn(Arrays.<View>asList()); Assert.assertFalse(importAction.canHandle(mockContext)); Mockito.when(mockContext.getSelectedManifestations()) .thenReturn(Arrays.<View>asList(mockView, mockView)); Assert.assertFalse(importAction.canHandle(mockContext)); Mockito.when(mockContext.getSelectedManifestations()) .thenReturn(Arrays.<View>asList(mockView)); Assert.assertTrue(importAction.canHandle(mockContext)); }
@Override public boolean canHandle(ActionContext context) { currentContext = context; return context.getSelectedManifestations().size() == 1; }
ImportAction extends ContextAwareAction implements PropertyChangeListener { @Override public boolean canHandle(ActionContext context) { currentContext = context; return context.getSelectedManifestations().size() == 1; } }
ImportAction extends ContextAwareAction implements PropertyChangeListener { @Override public boolean canHandle(ActionContext context) { currentContext = context; return context.getSelectedManifestations().size() == 1; } ImportAction(); }
ImportAction extends ContextAwareAction implements PropertyChangeListener { @Override public boolean canHandle(ActionContext context) { currentContext = context; return context.getSelectedManifestations().size() == 1; } ImportAction(); @Override void actionPerformed(ActionEvent e); @Override void propertyChange(PropertyChangeEvent evt); List<File> selectFiles(Component source); @Override boolean canHandle(ActionContext context); @Override boolean isEnabled(); }
ImportAction extends ContextAwareAction implements PropertyChangeListener { @Override public boolean canHandle(ActionContext context) { currentContext = context; return context.getSelectedManifestations().size() == 1; } ImportAction(); @Override void actionPerformed(ActionEvent e); @Override void propertyChange(PropertyChangeEvent evt); List<File> selectFiles(Component source); @Override boolean canHandle(ActionContext context); @Override boolean isEnabled();  }