All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.acceptance-test.utils.validator.test.utils.mustache Maven / Gradle / Ivy

Go to download

Gradle plugin to create a clean application in Java that already works, It follows our best practices!

There is a newer version: 3.20.10
Show newest version
package {{package}}.utils;

import com.atlassian.oai.validator.OpenApiInteractionValidator;
import com.atlassian.oai.validator.model.Request;
import com.atlassian.oai.validator.model.Response;
import com.atlassian.oai.validator.model.SimpleResponse;

import com.atlassian.oai.validator.report.ValidationReport;

public class ValidatorTestUtils {
  public static String contentType = "application/json";
  public static final String POST = "POST";
  public static final String GET = "GET";
  public static final String PUT = "PUT";
  public static final String DELETE = "DELETE";
  public static final String OPTIONS = "OPTIONS";
  public static final String HEAD = "HEAD";

  public static void setContentType(String _contentType) {
    contentType = _contentType;
  }

  public static ValidationReport validateResponseSchema(String oasUrl, String responseJson,
      String path, String method, int status) {

    OpenApiInteractionValidator validator = OpenApiInteractionValidator
        .createForSpecificationUrl(oasUrl).build();

    Response response = SimpleResponse.Builder
        .status(status)
        .withContentType(contentType)
        .withBody(responseJson)
        .build();

    return validator.validateResponse(path, Request.Method.valueOf(method), response);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy