@Test public void testIsEnabled() throws Exception { AbstractComponent componentWithExternalKey = Mockito.mock(AbstractComponent.class); Mockito.when(componentWithExternalKey.getExternalKey()).thenReturn("key"); AbstractComponent componentWithoutExternalKey = Mockito.mock(AbstractComponent.class); Field f = DuplicateAction.class.getDeclaredField("actionContext"); f.setAccessible(true); ActionContextImpl actionContext = new ActionContextImpl(); f.set(action, actionContext); actionContext.setTargetComponent(componentWithoutExternalKey); Assert.assertTrue(action.isEnabled()); actionContext.setTargetComponent(componentWithExternalKey); Assert.assertFalse(action.isEnabled()); }
@Override public boolean isEnabled() { AbstractComponent component = actionContext.getTargetComponent(); if (component == null || component.getExternalKey() != null) return false; return true; }
DuplicateAction extends ContextAwareAction { @Override public boolean isEnabled() { AbstractComponent component = actionContext.getTargetComponent(); if (component == null || component.getExternalKey() != null) return false; return true; } }
DuplicateAction extends ContextAwareAction { @Override public boolean isEnabled() { AbstractComponent component = actionContext.getTargetComponent(); if (component == null || component.getExternalKey() != null) return false; return true; } DuplicateAction(); }
DuplicateAction extends ContextAwareAction { @Override public boolean isEnabled() { AbstractComponent component = actionContext.getTargetComponent(); if (component == null || component.getExternalKey() != null) return false; return true; } DuplicateAction(); @Override void actionPerformed(ActionEvent e); @Override boolean canHandle(ActionContext context); @Override boolean isEnabled(); }
DuplicateAction extends ContextAwareAction { @Override public boolean isEnabled() { AbstractComponent component = actionContext.getTargetComponent(); if (component == null || component.getExternalKey() != null) return false; return true; } DuplicateAction(); @Override void actionPerformed(ActionEvent e); @Override boolean canHandle(ActionContext context); @Override boolean isEnabled();  }