### Question:
SwarmActionFactory implements WaspActionFactory { public WaspAction getAction(Action action) { if (action != null) try { return getAction(action.getName()); } catch (IllegalArgumentException e) { } return null; } SwarmActionFactory(Object key); WaspAction getAction(Action action); WaspAction getAction(String actions); SwarmAction getAction(int actions); SwarmAction getAction(Class<? extends WaspAction> waspActionClass); SwarmAction register(Class<? extends WaspAction> waspActionClass,
		String name); final int getNumberOfRegisteredClasses(); List<WaspAction> getRegisteredActions(); void destroy();  }### Answer:
@Test public void testGetActionAction() { WaspAction action = factory.getAction(Component.RENDER); assertNotNull(action); assertEquals(factory.getAction(Render.class), action); assertEquals(factory.getAction("render"), action); Action wicketAction = new Action("inherit, render"); action = factory.getAction(wicketAction); assertNotNull(action); assertEquals(factory.getAction(wicketAction.getName()), action); assertNull(factory.getAction((Action)null)); assertNull(factory.getAction(new Action("foo"))); }
@Test public void testGetActionString() { WaspAction action = factory.getAction(Action.RENDER); assertNotNull(action); assertEquals(factory.getAction(Render.class), action); assertEquals(factory.getAction(Access.class), factory.getAction((String)null)); assertEquals(factory.getAction(Access.class), factory.getAction("")); try { factory.getAction("foo"); fail("foo is not registered action"); } catch (IllegalArgumentException e) { log.debug(e.getMessage()); } }
@Test public void testGetActionInt() { WaspAction action; try { action = factory.getAction(-1); fail("found action that should not be registered by the default factory: " + action); } catch (IllegalArgumentException e) { log.debug(e.getMessage()); } String[] names = new String[] { "access", "access, inherit", "access, render", "access, inherit, render", "access", "access, inherit", "access, render, enable", "access, inherit, render, enable" }; for (int i = 0; i < 8; i++) { action = factory.getAction(i); assertNotNull(action, "action " + i + "was null"); assertEquals(names[i], action.getName(), "iteration " + i); } try { action = factory.getAction(8); fail("found action that should not be registered by the default factory: " + action); } catch (IllegalArgumentException e) { log.debug(e.getMessage()); } }