### Question:
APIController { public static Action getAction(String actionKey) throws InvalidParameterException { Action action = APIController.actionMap.get(actionKey); if (action != null) { return action; } Object theMutex = APIController.RUNNING_THREAD.get(actionKey); if (theMutex == null) { theMutex = new Object(); } while (true) { synchronized (theMutex) { action = APIController.actionMap.get(actionKey); if (action != null) { return action; } APIController.LOCK_THREADS.lock(); if (!APIController.RUNNING_THREAD.containsKey(actionKey)) { APIController.RUNNING_THREAD.put(actionKey, theMutex); APIController.LOCK_THREADS.unlock(); final Matcher theMatcher = APIController.ROOT_REGEX.matcher(actionKey); if (theMatcher.matches()) { final String theRoot = APIController.PACKAGE_ROOTS.get(theMatcher.group(1)); if (theRoot == null) { APIController.removeRunningThread(actionKey); throw new InvalidParameterException(APIErrorMessage.MISSING_PARAMETER, actionKey); } final String className = theRoot + theMatcher.group(2) + "." + StringUtils.capitalize(theMatcher.group(3)); try { final Class actionClass = Class.forName(className); action = (Action) actionClass.newInstance(); APIController.actionMap.put(actionKey, action); } catch (final ClassNotFoundException e) { throw new InvalidParameterException(APIErrorMessage.INVALID_PARAMETER_BECAUSE, "className", className); } catch (final InstantiationException e) { throw new InvalidParameterException(APIErrorMessage.NO_SUCH_METHOD, net.violet.common.StringShop.EMPTY_STRING); } catch (final IllegalAccessException e) { throw new InvalidParameterException(APIErrorMessage.NO_SUCH_METHOD, net.violet.common.StringShop.EMPTY_STRING); } finally { APIController.removeRunningThread(actionKey); } } else { APIController.removeRunningThread(actionKey); throw new InvalidParameterException(APIErrorMessage.NO_SUCH_METHOD, net.violet.common.StringShop.EMPTY_STRING); } return action; } theMutex = APIController.RUNNING_THREAD.get(actionKey); APIController.LOCK_THREADS.unlock(); } } }  static Action getAction(String actionKey);  }### Answer:
@Test public void testGetName() throws APIException { Assert.assertEquals(APIConstants.GET_PACKAGE_ACTION, APIController.getAction(APIConstants.GET_PACKAGE_ACTION).getName()); }
@Test(expected = InvalidParameterException.class) public void testInvalidAction() throws APIException { Assert.assertEquals(this.bad_action, APIController.getAction(this.bad_action)); Assert.assertEquals(this.bad_action, APIController.getAction(this.bad_action)); }