PlaceObjectsInMultiAction extends ContextAwareAction { @Override public void actionPerformed(ActionEvent e) { Set<AbstractComponent> sourceComponents = new LinkedHashSet<AbstractComponent>(); for (View manifestation : selectedManifestations) sourceComponents.add(manifestation.getManifestedComponent()); final String name = getNewMulti(sourceComponents); if (name.isEmpty()) return; final AbstractComponent multi = createNewMulti(sourceComponents); if (multi == null) { showErrorInCreateMulti(); } else { multi.setDisplayName(name); SwingUtilities.invokeLater(new Runnable() { public void run() { openNewMulti(name, multi); } }); } } PlaceObjectsInMultiAction(); @Override void actionPerformed(ActionEvent e); @Override boolean canHandle(ActionContext context); @Override boolean isEnabled();  }
@Test(dependsOnMethods = {"testIsEnabled"}) public void testActionPerformedSuccessfulCase() throws Exception { reset(); setResult = true; action.actionPerformed(new ActionEvent(viewManifestation1, 0, "")); final Semaphore s = new Semaphore(1); s.acquire(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { s.release(); } }); s.tryAcquire(5, TimeUnit.SECONDS); Assert.assertEquals(success, 1); Assert.assertEquals(fail, 0); Assert.assertNotNull(sourceComponents); Assert.assertEquals(sourceComponents.size(), 2); Assert.assertTrue(sourceComponents.contains(componentA)); Assert.assertTrue(sourceComponents.contains(componentB)); }
@Test(dependsOnMethods = {"testIsEnabled"}) public void testActionPerformedFailedCase() { reset(); setResult = false; action.actionPerformed(new ActionEvent(viewManifestation1, 0,"")); Assert.assertEquals(success,0); Assert.assertEquals(fail,1); Assert.assertEquals(sourceComponents.size(), 2); }