private void addMethod(
      ActionType action,
      Resource res,
      IMethodModel m,
      IDocInfo documentation,
      String returnName,
      String parameterName) {
    Action value = new Action();

    value.setType(action);
    res.getActions().put(action, value);
    IParameterModel[] parameters = m.getParameters();
    String[] responseCodes = new String[] {ResourceVisitor.DEFAULT_RESPONSE};
    String[] responseDescriptions = new String[] {null};
    if (config != null) {
      responseCodes = new String[] {config.getResponseCode(action)};
    }
    IAnnotationModel annotation = m.getAnnotation(ResourceVisitor.API_RESPONSE);
    if (annotation != null) {
      responseCodes = new String[] {annotation.getValue(ResourceVisitor.CODE)};
      responseDescriptions = new String[] {annotation.getValue(ResourceVisitor.MESSAGE)};
    }
    annotation = m.getAnnotation(ResourceVisitor.API_RESPONSES);
    if (annotation != null) {
      IAnnotationModel[] subAnnotations = annotation.getSubAnnotations("value");
      responseCodes = new String[subAnnotations.length];
      responseDescriptions = new String[subAnnotations.length];
      int a = 0;
      for (IAnnotationModel mq : subAnnotations) {
        responseCodes[a++] = mq.getValue(ResourceVisitor.CODE);
        responseDescriptions[a - 1] = mq.getValue(ResourceVisitor.MESSAGE);
      }
    }
    for (IParameterModel pm : parameters) {
      if (pm.hasAnnotation(QUERY_PARAM)) {
        String annotationValue = pm.getAnnotationValue(QUERY_PARAM);
        String type = pm.getType();
        QueryParameter value2 = new QueryParameter();
        configureParam(pm, value2);
        proceedType(type, value2, pm);
        String text = documentation.getDocumentation(pm.getName());
        if (!"".equals(text)) { // $NON-NLS-1$
          value2.setDescription(text);
        }
        value.getQueryParameters().put(annotationValue, value2);
      }
    }
    for (IParameterModel pm : parameters) {
      if (pm.hasAnnotation(HEADER_PARAM)) {
        String annotationValue = pm.getAnnotationValue(HEADER_PARAM);
        Header value2 = new Header();
        configureParam(pm, value2);
        proceedType(pm.getType(), value2, pm);
        String text = documentation.getDocumentation(pm.getName());
        if (!"".equals(text)) { // $NON-NLS-1$
          value2.setDescription(text);
        }
        value.getHeaders().put(annotationValue, value2);
      }
    }
    for (IParameterModel pm : parameters) {
      if (pm.hasAnnotation(PATH_PARAM)) {
        String annotationValue = pm.getAnnotationValue(PATH_PARAM);
        UriParameter value2 = new UriParameter();
        configureParam(pm, value2);
        String text = documentation.getDocumentation(pm.getName());
        if (!"".equals(text)) { // $NON-NLS-1$
          value2.setDescription(text);
        }
        proceedType(pm.getType(), value2, pm);
        res.getUriParameters().put(annotationValue, value2);
      }
    }

    String[] consumesValue = m.getAnnotationValues(CONSUMES);
    if (consumesValue == null) {
      consumesValue = classConsumes;
    }
    if (consumesValue != null) {
      for (String s : consumesValue) {
        s = sanitizeMediaType(s);
        MimeType bodyType = new MimeType();
        if (s.contains(XML)) {
          bodyType.setSchema(parameterName);
          if (parameterName != null) {
            bodyType.setExample(EXAMPLES_PREFFIX + parameterName + XML_FILE_EXT);
            bodyType.setExampleOrigin(EXAMPLES_PREFFIX + parameterName + XML_FILE_EXT);
          }
        }
        if (s.contains(JSON)) {
          if (parameterName != null) {
            bodyType.setSchema(parameterName + ResourceVisitor.JSONSCHEMA); // $NON-NLS-1$
            bodyType.setExample(EXAMPLES_PREFFIX + parameterName + JSON_FILE_EXT);
            bodyType.setExampleOrigin(EXAMPLES_PREFFIX + parameterName + JSON_FILE_EXT);
          }
        }
        bodyType.setType(s);
        if (s.contains(FORM)) {
          for (IParameterModel pm : parameters) {
            if (pm.hasAnnotation(FORM_PARAM)) {
              String annotationValue = pm.getAnnotationValue(FORM_PARAM);
              FormParameter vl = new FormParameter();
              configureParam(pm, vl);
              String text = documentation.getDocumentation(pm.getName());
              if (!"".equals(text)) { // $NON-NLS-1$
                vl.setDescription(text);
              }
              proceedType(pm.getType(), vl, pm);
              ArrayList<FormParameter> arrayList = new ArrayList<FormParameter>();
              arrayList.add(vl);
              if (bodyType.getFormParameters() == null) {
                bodyType.setFormParameters(new HashMap<String, java.util.List<FormParameter>>());
              }
              bodyType.getFormParameters().put(annotationValue, arrayList);
            }
          }
        }
        value.getBody().put(s, bodyType);
      }
    }
    String[] producesValue = m.getAnnotationValues(PRODUCES);
    if (producesValue == null) {
      producesValue = classProduces;
    }
    int a = 0;
    for (String responseCode : responseCodes) {
      if (producesValue != null) {
        Response value2 = new Response();
        String text = documentation.getReturnInfo();
        String respDesc = responseDescriptions[a];
        if (respDesc != null && respDesc.length() > 0) {
          text = respDesc;
        }
        a++;
        if (!"".equals(text)) { // $NON-NLS-1$
          value2.setDescription(text);
        }
        for (String s : producesValue) {
          s = sanitizeMediaType(s);
          MimeType mimeType = new MimeType();
          if (returnName != null) {
            if (s.contains(XML)) {
              mimeType.setSchema(returnName);
              if (returnName != null) {
                mimeType.setExample(EXAMPLES_PREFFIX + returnName + XML_FILE_EXT);
                mimeType.setExampleOrigin(EXAMPLES_PREFFIX + returnName + XML_FILE_EXT);
              }
            }
            if (s.contains(JSON)) {
              if (returnName != null) {
                mimeType.setSchema(returnName + ResourceVisitor.JSONSCHEMA); // $NON-NLS-1$
                mimeType.setExample(EXAMPLES_PREFFIX + returnName + JSON_FILE_EXT);
                mimeType.setExampleOrigin(EXAMPLES_PREFFIX + returnName + JSON_FILE_EXT);
              }
            }
          }
          mimeType.setType(s);
          value2.getBody().put(s, mimeType);
        }
        value.getResponses().put(responseCode, value2); // $NON-NLS-1$
      } else {
        Response value2 = new Response();
        String text = documentation.getReturnInfo();
        if (!"".equals(text)) { // $NON-NLS-1$
          value2.setDescription(text);
        }
        value.getResponses().put(responseCode, value2); // $NON-NLS-1$
      }
    }
  }
  private void verifyFullDump(Raml source, String dump) {
    Raml target = verifyDump(source, dump);

    // *********** URI PARAMETERS ***********

    UriParameter srcHost = source.getBaseUriParameters().get("host");
    UriParameter tgtHost = target.getBaseUriParameters().get("host");
    assertThat(tgtHost.getDisplayName(), is(srcHost.getDisplayName()));
    assertThat(tgtHost.getDescription(), is(srcHost.getDescription()));
    assertThat(tgtHost.getType(), is(srcHost.getType()));
    assertThat(tgtHost.getMinLength(), is(srcHost.getMinLength()));
    assertThat(tgtHost.getMaxLength(), is(srcHost.getMaxLength()));
    assertThat(tgtHost.getPattern(), is(srcHost.getPattern()));

    UriParameter srcPort = source.getBaseUriParameters().get("port");
    UriParameter tgtPort = target.getBaseUriParameters().get("port");
    assertThat(tgtPort.getType(), is(srcPort.getType()));
    assertThat(tgtPort.getMinimum(), is(srcPort.getMinimum()));
    assertThat(tgtPort.getMaximum(), is(srcPort.getMaximum()));

    UriParameter srcPath = source.getBaseUriParameters().get("path");
    UriParameter tgtPath = target.getBaseUriParameters().get("path");
    assertThat(tgtPath.getType(), is(srcPath.getType()));
    assertThat(tgtPath.getEnumeration().size(), is(srcPath.getEnumeration().size()));
    assertThat(tgtPath.getEnumeration().get(0), is(srcPath.getEnumeration().get(0)));
    assertThat(tgtPath.getEnumeration().get(1), is(srcPath.getEnumeration().get(1)));
    assertThat(tgtPath.getEnumeration().get(2), is(srcPath.getEnumeration().get(2)));

    // *********** DOCUMENTATION ***********

    List<DocumentationItem> srcDoc = source.getDocumentation();
    List<DocumentationItem> tgtDoc = target.getDocumentation();
    assertThat(tgtDoc.get(0).getTitle(), is(srcDoc.get(0).getTitle()));
    assertThat(tgtDoc.get(0).getContent(), is(srcDoc.get(0).getContent()));

    // *********** GLOBAL SCHEMAS ***********

    List<Map<String, String>> srcSchemas = source.getSchemas();
    List<Map<String, String>> tgtSchemas = target.getSchemas();
    assertThat(tgtSchemas.size(), is(srcSchemas.size()));
    assertThat(tgtSchemas.get(0).get("league-json"), is(srcSchemas.get(0).get("league-json")));
    assertThat(tgtSchemas.get(1).get("league-xml"), is(srcSchemas.get(1).get("league-xml")));

    // *********** FORM PARAMETERS ***********

    Map<String, List<FormParameter>> srcFormParams =
        source
            .getResource("/media")
            .getAction(GET)
            .getBody()
            .get("multipart/form-data")
            .getFormParameters();
    Map<String, List<FormParameter>> tgtFormParams =
        target
            .getResource("/media")
            .getAction(GET)
            .getBody()
            .get("multipart/form-data")
            .getFormParameters();
    assertThat(srcFormParams.size(), is(tgtFormParams.size()));
    assertThat(srcFormParams.get("form-1").size(), is(tgtFormParams.get("form-1").size()));
    assertThat(
        srcFormParams.get("form-1").get(0).getDisplayName(),
        is(tgtFormParams.get("form-1").get(0).getDisplayName()));
    assertThat(srcFormParams.get("form-2").size(), is(tgtFormParams.get("form-2").size()));
    assertThat(
        srcFormParams.get("form-2").get(0).getDisplayName(),
        is(tgtFormParams.get("form-2").get(0).getDisplayName()));

    // *********** RESOURCE TYPES ************

    assertThat(target.getResourceTypes().size(), is(source.getResourceTypes().size()));
    assertThat(
        target.getResourceTypes().get(0).get("basic").getDisplayName(),
        is(source.getResourceTypes().get(0).get("basic").getDisplayName()));
    assertThat(
        target.getResourceTypes().get(1).get("complex").getDisplayName(),
        is(source.getResourceTypes().get(1).get("complex").getDisplayName()));

    assertThat(target.getResource("/").getType(), is(source.getResource("/").getType()));
    assertThat(target.getResource("/media").getType(), is(source.getResource("/media").getType()));

    // *********** TRAITS ************

    assertThat(target.getTraits().size(), is(source.getTraits().size()));
    assertThat(
        target.getTraits().get(0).get("simple").getDisplayName(),
        is(source.getTraits().get(0).get("simple").getDisplayName()));
    assertThat(
        target.getTraits().get(1).get("knotty").getDisplayName(),
        is(source.getTraits().get(1).get("knotty").getDisplayName()));

    assertThat(
        target.getResource("/").getAction(HEAD).getIs(),
        is(source.getResource("/").getAction(HEAD).getIs()));

    // *********** SECURITY SCHEMES ************

    assertThat(target.getSecuritySchemes().size(), is(source.getSecuritySchemes().size()));
    SecurityScheme tOauth2 = target.getSecuritySchemes().get(0).get("oauth_2_0");
    SecurityScheme sOauth2 = source.getSecuritySchemes().get(0).get("oauth_2_0");
    assertThat(tOauth2.getDescription(), is(sOauth2.getDescription()));
    assertThat(
        tOauth2.getDescribedBy().getHeaders().size(),
        is(sOauth2.getDescribedBy().getHeaders().size()));
    assertThat(
        tOauth2.getDescribedBy().getHeaders().get("Authorization").getDescription(),
        is(sOauth2.getDescribedBy().getHeaders().get("Authorization").getDescription()));
    assertThat(
        tOauth2.getDescribedBy().getQueryParameters().size(),
        is(sOauth2.getDescribedBy().getQueryParameters().size()));
    assertThat(
        tOauth2.getDescribedBy().getQueryParameters().get("access_token").getDescription(),
        is(sOauth2.getDescribedBy().getQueryParameters().get("access_token").getDescription()));
    assertThat(
        tOauth2.getDescribedBy().getResponses().size(),
        is(sOauth2.getDescribedBy().getResponses().size()));
    assertThat(
        tOauth2.getDescribedBy().getResponses().get("401").getDescription(),
        is(sOauth2.getDescribedBy().getResponses().get("401").getDescription()));
    assertThat(tOauth2.getSettings().size(), is(sOauth2.getSettings().size()));
    assertThat(
        tOauth2.getSettings().get("authorizationUrl").size(),
        is(sOauth2.getSettings().get("authorizationUrl").size()));
    assertThat(
        sOauth2.getSettings().get("authorizationUrl").get(0),
        is("https://www.dropbox.com/1/oauth2/authorize"));
    assertThat(
        tOauth2.getSettings().get("authorizationUrl").get(0),
        is(sOauth2.getSettings().get("authorizationUrl").get(0)));

    assertThat(
        target.getResource("/").getSecuredBy().size(),
        is(source.getResource("/").getSecuredBy().size()));
    assertThat(
        target.getResource("/").getSecuredBy().get(0).getName(),
        is(source.getResource("/").getSecuredBy().get(0).getName()));
    assertThat(
        target.getResource("/").getSecuredBy().get(0).getParameters().size(),
        is(source.getResource("/").getSecuredBy().get(0).getParameters().size()));
    assertThat(
        target.getResource("/").getSecuredBy().get(0).getParameters().get("scopes").get(0),
        is(source.getResource("/").getSecuredBy().get(0).getParameters().get("scopes").get(0)));
    assertThat(
        target.getResource("/").getSecuredBy().get(1).getName(),
        is(source.getResource("/").getSecuredBy().get(1).getName()));
    assertThat(
        target.getResource("/").getSecuredBy().get(2).getName(),
        is(source.getResource("/").getSecuredBy().get(2).getName()));

    // *********** PROTOCOLS ************

    assertThat(target.getProtocols().size(), is(source.getProtocols().size()));
    assertThat(target.getProtocols().get(0), is(source.getProtocols().get(0)));
    assertThat(target.getProtocols().get(1), is(source.getProtocols().get(1)));
  }