test_class.declarator: FAKE_CMD_NAME = "fakecmdname"
test_class.modifier: protected static final
test_class.original_string: protected static final String FAKE_CMD_NAME = "fakecmdname";
test_class.type: String
test_class.var_name: FAKE_CMD_NAME
test_class.declarator: FAKE_CMD_ROLE_NAME = "fakecmdrolename"
test_class.modifier: protected static final
test_class.original_string: protected static final String FAKE_CMD_ROLE_NAME = "fakecmdrolename";
test_class.type: String
test_class.var_name: FAKE_CMD_ROLE_NAME
test_class.declarator: loggerOutput
test_class.modifier: protected
test_class.original_string: protected String loggerOutput;
test_class.type: String
test_class.var_name: loggerOutput
test_class.file: server/src/test/java/com/cloud/api/dispatch/ParamGenericValidationWorkerTest.java
test_class.identifier: ParamGenericValidationWorkerTest
test_case.body: @Test
      public void testHandle() throws ResourceAllocationException {
          // Prepare
          final BaseCmd cmd = new FakeCmd();
          final Map<String, String> params = new HashMap<String, String>();
          params.put(ApiConstants.COMMAND, "");
          params.put(ApiConstants.ACCOUNT_ID, "");
          params.put(ApiConstants.CTX_START_EVENT_ID, "");
          params.put(ApiConstants.COMMAND, "");
          params.put(ApiConstants.CMD_EVENT_TYPE, "");
          params.put(ApiConstants.USERNAME, "");
          params.put(ApiConstants.USER_ID, "");
          params.put(ApiConstants.PASSWORD, "");
          params.put(ApiConstants.DOMAIN, "");
          params.put(ApiConstants.DOMAIN_ID, "");
          params.put(ApiConstants.DOMAIN__ID, "");
          params.put(ApiConstants.SESSIONKEY, "");
          params.put(ApiConstants.RESPONSE, "");
          params.put(ApiConstants.PAGE, "");
          params.put(ApiConstants.USER_API_KEY, "");
          params.put(ApiConstants.API_KEY, "");
          params.put(ApiConstants.PAGE_SIZE, "");
          params.put(ApiConstants.HTTPMETHOD, "");
          params.put(ApiConstants.SIGNATURE, "");
          params.put(ApiConstants.CTX_ACCOUNT_ID, "");
          params.put(ApiConstants.CTX_START_EVENT_ID, "");
          // Make sure it's case insensitive
          params.put(ApiConstants.CTX_START_EVENT_ID, "");
          params.put(ApiConstants.CTX_START_EVENT_ID.toLowerCase(), "");
          params.put(ApiConstants.CTX_USER_ID.toUpperCase(), "");
          params.put(ApiConstants.CTX_USER_ID, "");
          params.put(ApiConstants.UUID, "");
          params.put(ApiConstants.ID, "");
          params.put("_", "");
          params.put("addedParam", "");
  
          Account account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
          UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone", UUID.randomUUID().toString(), User.Source.UNKNOWN);
          CallContext.register(user, account);
          // Execute
          try {
              driveTest(cmd, params);
          } finally {
              CallContext.unregister();
          }
  
          // Assert
          assertEquals("There should be no errors since there are no unknown parameters for this command class", null, loggerOutput);
      }
test_case.class_method_signature: ParamGenericValidationWorkerTest.testHandle()
test_case.full_signature: @Test public void testHandle()
test_case.identifier: testHandle
test_case.invocations: put put put put put put put put put put put put put put put put put put put put put put put toLowerCase put toUpperCase put put put put put toString randomUUID register driveTest unregister assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testHandle()
focal_class.declarator: s_logger = Logger.getLogger(ParamGenericValidationWorker.class.getName())
focal_class.modifier: static
focal_class.original_string: static Logger s_logger = Logger.getLogger(ParamGenericValidationWorker.class.getName());
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.declarator: defaultParamNames = new ArrayList<String>()
focal_class.modifier: protected static final
focal_class.original_string: protected static final List<String> defaultParamNames = new ArrayList<String>();
focal_class.type: List<String>
focal_class.var_name: defaultParamNames
focal_class.declarator: ERROR_MSG_PREFIX = "Unknown parameters :"
focal_class.modifier: protected static final
focal_class.original_string: protected static final String ERROR_MSG_PREFIX = "Unknown parameters :";
focal_class.type: String
focal_class.var_name: ERROR_MSG_PREFIX
focal_class.file: server/src/main/java/com/cloud/api/dispatch/ParamGenericValidationWorker.java
focal_class.identifier: ParamGenericValidationWorker
focal_class.interfaces: implements DispatchWorker
focal_class.class_method_signature: ParamGenericValidationWorker.handle(final DispatchTask task)
focal_class.full_signature: @SuppressWarnings("rawtypes") @Override public void handle(final DispatchTask task)
focal_class.identifier: handle
focal_class.modifiers: @SuppressWarnings("rawtypes") @Override public
focal_class.parameters: (final DispatchTask task)
focal_class.return: void
focal_class.signature: void handle(final DispatchTask task)
focal_class.class_method_signature: ParamGenericValidationWorker.getParamNamesForCommand(final BaseCmd cmd)
focal_class.full_signature: protected List<String> getParamNamesForCommand(final BaseCmd cmd)
focal_class.identifier: getParamNamesForCommand
focal_class.modifiers: protected
focal_class.parameters: (final BaseCmd cmd)
focal_class.return: List<String>
focal_class.signature: List<String> getParamNamesForCommand(final BaseCmd cmd)
focal_method.body: @SuppressWarnings("rawtypes")
      @Override
      public void handle(final DispatchTask task) {
          final BaseCmd cmd = task.getCmd();
          final Map params = task.getParams();
  
          final List<String> expectedParamNames = getParamNamesForCommand(cmd);
  
          final StringBuilder errorMsg = new StringBuilder(ERROR_MSG_PREFIX);
          boolean foundUnknownParam = false;
          for (final Object actualParamName : params.keySet()) {
              // If none of the expected params matches, we have an unknown param
              boolean matchedCurrentParam = false;
              for (final String expectedName : expectedParamNames) {
                  if (expectedName.equalsIgnoreCase((String) actualParamName)) {
                      matchedCurrentParam = true;
                      break;
                  }
              }
              if (!matchedCurrentParam && !((String)actualParamName).equalsIgnoreCase("expires") && !((String)actualParamName).equalsIgnoreCase("signatureversion")) {
                  errorMsg.append(" ").append(actualParamName);
                  foundUnknownParam= true;
              }
          }
  
          if (foundUnknownParam) {
              s_logger.warn(String.format("Received unknown parameters for command %s. %s", cmd.getActualCommandName(), errorMsg));
          }
      }
focal_method.class_method_signature: ParamGenericValidationWorker.handle(final DispatchTask task)
focal_method.full_signature: @SuppressWarnings("rawtypes") @Override public void handle(final DispatchTask task)
focal_method.identifier: handle
focal_method.invocations: getCmd getParams getParamNamesForCommand keySet equalsIgnoreCase equalsIgnoreCase equalsIgnoreCase append append warn format getActualCommandName
focal_method.modifiers: @SuppressWarnings("rawtypes") @Override public
focal_method.parameters: (final DispatchTask task)
focal_method.return: void
focal_method.signature: void handle(final DispatchTask task)