org.mockserver.client.server.MockServerClient Java Examples

The following examples show how to use org.mockserver.client.server.MockServerClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BotsHttpClientTest.java    From geoportal-server-harvester with Apache License 2.0 7 votes vote down vote up
@Before
public void setup() throws IOException {
  client = new MockServerClient("localhost", 5000);
  client.when(
                  request()
                  .withMethod("GET")
                  .withPath("/robots.txt")
          )
          .respond(
                  response()
                  .withStatusCode(200)
                  .withBody(readAndClose(getClass().getResourceAsStream("/robots.txt")))
          );
  client.when(
                  request()
                  .withMethod("GET")
                  .withPath("/data.txt")
          )
          .respond(
                  response()
                  .withStatusCode(200)
                  .withBody("some data")
          );
}
 
Example #2
Source File: MockServerLiveTest.java    From tutorials with MIT License 6 votes vote down vote up
private void createExpectationForInvalidAuth() {
    new MockServerClient("127.0.0.1", 1080)
            .when(
                request()
                    .withMethod("POST")
                    .withPath("/validate")
                    .withHeader("\"Content-type\", \"application/json\"")
                    .withBody(exact("{username: 'foo', password: 'bar'}")),
                    exactly(1)
            )
            .respond(
                response()
                    .withStatusCode(401)
                    .withHeaders(
                        new Header("Content-Type", "application/json; charset=utf-8"),
                        new Header("Cache-Control", "public, max-age=86400")
                )
                    .withBody("{ message: 'incorrect username and password combination' }")
                    .withDelay(TimeUnit.SECONDS,1)
            );
}
 
Example #3
Source File: CollaboratorServiceExTests.java    From HubTurbo with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void getCollaborators_validRepoId_successful() throws IOException {
    MockServerClient mockServer = ClientAndServer.startClientAndServer(8888);
    String sampleCollaborators = TestUtils.readFileFromResource(this, "tests/CollaboratorsSample.json");

    mockServer.when(
            request()
                .withPath(TestUtils.API_PREFIX + "/repos/hubturbo/tests/collaborators")
    ).respond(response().withBody(sampleCollaborators));

    Type listOfUsers = new TypeToken<List<User>>() {}.getType();
    List<User> expectedCollaborators = new Gson().fromJson(sampleCollaborators, listOfUsers);
    List<User> actualCollaborators = service.getCollaborators(RepositoryId.createFromId("hubturbo/tests"));

    assertEquals(expectedCollaborators.size(), actualCollaborators.size());

    for (int i = 0; i < expectedCollaborators.size(); i++) {
        assertEquals(expectedCollaborators.get(i).getLogin(), actualCollaborators.get(i).getLogin());
        assertEquals(expectedCollaborators.get(i).getName(), actualCollaborators.get(i).getName());
        assertEquals(true, actualCollaborators.get(i).getName() != null);
    }

    mockServer.stop();
}
 
Example #4
Source File: MockServerUtils.java    From pagerduty-client with MIT License 6 votes vote down vote up
private static void prepareMockServer(MockServerClient mockServerClient, Incident incident, int statusCode, String responseBody) throws JsonProcessingException {
    ObjectMapper mapper = new ObjectMapper();
    mockServerClient
            .when(request()
                            .withMethod("POST")
                            .withPath(EVENT_END_POINT)
                            .withBody(exact(mapper.writeValueAsString(incident))),
                    exactly(1))
            .respond(response()
                            .withStatusCode(statusCode)
                            .withHeaders(
                                    new Header("Server", "MockServer"),
                                    new Header("Date", new Date().toString()),
                                    new Header("Content-Type", "application/json; charset=utf-8")
                            )
                            .withBody(responseBody)
                            .withDelay(new Delay(TimeUnit.SECONDS, 1))
            );
}
 
Example #5
Source File: TestLogical.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testWrite() throws Exception {
  VaultConfiguration conf = VaultConfigurationBuilder.newVaultConfiguration()
      .withAddress(address)
      .withToken(token)
      .build();

  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
          request()
              .withMethod("POST")
              .withHeader(tokenHeader)
              .withPath("/v1/secret/hello")
              .withBody("{\"value\":\"world!\"}"),
          exactly(1)
      )
      .respond(
          response()
              .withStatusCode(NO_CONTENT_204.code())
              .withHeader(contentJson)
      );

  VaultClient vault = new VaultClient(conf);
  vault.logical().write("secret/hello", ImmutableMap.<String, Object>of("value", "world!"));
}
 
Example #6
Source File: TestAuth.java    From datacollector with Apache License 2.0 6 votes vote down vote up
@Test
public void testEnableAuth() throws Exception {
  VaultConfiguration conf = VaultConfigurationBuilder.newVaultConfiguration()
      .withAddress(address)
      .withToken(token)
      .build();

  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
      HttpRequest.request()
          .withMethod("POST")
          .withHeader(tokenHeader)
          .withPath("/v1/sys/auth/app-id")
          .withBody("{\"type\":\"app-id\"}"),
      Times.exactly(1)
  )
  .respond(
      HttpResponse.response()
          .withStatusCode(HttpStatusCode.NO_CONTENT_204.code())
          .withHeader(contentJson)
  );

  VaultClient vault = new VaultClient(conf);
  assertTrue(vault.sys().auth().enable("app-id", "app-id"));
}
 
Example #7
Source File: TestAuthenticate.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testAppId() throws Exception {
  VaultConfiguration conf = VaultConfigurationBuilder.newVaultConfiguration()
      .withAddress(address)
      .withToken(token)
      .build();

  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
      request()
          .withMethod("POST")
          .withHeader(tokenHeader)
          .withPath("/v1/auth/app-id/login")
          .withBody("{\"app_id\":\"foo\",\"user_id\":\"bar\"}"),
      exactly(1)
  )
  .respond(
      response()
          .withStatusCode(OK_200.code())
          .withHeader(contentJson)
          .withBody(getBody("auth_app_id.json"))
  );

  VaultClient vault = new VaultClient(conf);
  Secret secret = vault.authenticate().appId("foo", "bar");

  assertEquals("26845a04-96f4-2b21-e404-c6e858d08a71", secret.getAuth().getClientToken());
  assertEquals("sha1:0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33", secret.getAuth().getMetadata().get("app-id"));
  assertEquals("sha1:62cdb7020ff920e5aa642c3d4066950dd1f01f4d", secret.getAuth().getMetadata().get("user-id"));
  assertEquals(0, secret.getLeaseDuration());
  assertEquals("", secret.getLeaseId());
  assertEquals(false, secret.isRenewable());
}
 
Example #8
Source File: MockServerLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
private void createExpectationForForward(){
    new MockServerClient("127.0.0.1", 1080)
        .when(
            request()
               .withMethod("GET")
               .withPath("/index.html"),
               exactly(1)
            )
            .forward(
                forward()
                    .withHost("www.mock-server.com")
                    .withPort(80)
                    .withScheme(HttpForward.Scheme.HTTP)
            );
}
 
Example #9
Source File: MockServerLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
private void verifyGetRequest() {
    new MockServerClient("localhost", 1080).verify(
            request()
                    .withMethod("GET")
                    .withPath("/index.html"),
            VerificationTimes.exactly(1)
    );
}
 
Example #10
Source File: MockServerLiveTest.java    From tutorials with MIT License 5 votes vote down vote up
private void verifyPostRequest() {
    new MockServerClient("localhost", 1080).verify(
            request()
                    .withMethod("POST")
                    .withPath("/validate")
                    .withBody(exact("{username: 'foo', password: 'bar'}")),
            VerificationTimes.exactly(1)
    );
}
 
Example #11
Source File: PullRequestServiceExTests.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Tests that getReviewComments method correctly receives 1 page of review comments
 * returned from a MockServer that emulates GitHub API service.
 */
@Test
public void testGetReviewComments() throws IOException {
    MockServerClient mockServer = ClientAndServer.startClientAndServer(8888);
    String sampleComments = TestUtils.readFileFromResource(this, "tests/ReviewCommentsSample.json");

    mockServer.when(
            request()
                    .withPath(TestUtils.API_PREFIX + "/repos/hubturbo/hubturbo/pulls/1125/comments")
                    .withQueryStringParameters(
                            new Parameter("per_page", "100"),
                            new Parameter("page", "1")
                    )
    ).respond(response().withBody(sampleComments));

    GitHubClient client = new GitHubClient("localhost", 8888, "http");
    PullRequestServiceEx service = new PullRequestServiceEx(client);

    Type listOfComments = new TypeToken<List<ReviewComment>>() {
    }.getType();
    List<ReviewComment> expectedComments = new Gson().fromJson(sampleComments, listOfComments);
    List<ReviewComment> actualComments = service.getReviewComments(
            RepositoryId.createFromId("hubturbo/hubturbo"), 1125);

    assertEquals(expectedComments.size(), actualComments.size());

    Comparator<ReviewComment> comparator = (a, b) -> (int) (a.getId() - b.getId());
    Collections.sort(expectedComments, comparator);
    Collections.sort(actualComments, comparator);

    for (int i = 0; i < expectedComments.size(); i++) {
        assertEquals(expectedComments.get(i).getId(), actualComments.get(i).getId());
    }

    mockServer.stop();

}
 
Example #12
Source File: TestLogical.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testRead() throws Exception {
  VaultConfiguration conf = VaultConfigurationBuilder.newVaultConfiguration()
      .withAddress(address)
      .withToken(token)
      .build();

  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
          request()
              .withMethod("GET")
              .withHeader(tokenHeader)
              .withPath("/v1/secret/streamsets"),
          exactly(1)
      )
      .respond(
          response()
              .withStatusCode(OK_200.code())
              .withHeader(contentJson)
              .withBody(getBody("logical_read.json"))
      );

  VaultClient vault = new VaultClient(conf);
  Secret secret = vault.logical().read("secret/streamsets");

  assertEquals(2592000, secret.getLeaseDuration());
  assertEquals("", secret.getLeaseId());
  assertEquals(false, secret.isRenewable());
  assertTrue(secret.getData().containsKey("ingest"));
  assertEquals("is fun", secret.getData().get("ingest"));
}
 
Example #13
Source File: TestLease.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void testRenew() throws Exception {
  VaultConfiguration conf = VaultConfigurationBuilder.newVaultConfiguration()
      .withAddress(address)
      .withToken(token)
      .build();

  String leaseId = "aws/creds/s3ReadOnly/895aad27-028e-301b-5475-906a6561f8f8";

  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
      HttpRequest.request()
          .withMethod("PUT")
          .withHeader(tokenHeader)
          .withPath("/v1/sys/renew/" + leaseId),
      Times.exactly(1)
  )
  .respond(
      HttpResponse.response()
          .withStatusCode(HttpStatusCode.OK_200.code())
          .withHeader(contentJson)
          .withBody(getBody("sys_lease_renew.json"))
  );

  VaultClient vault = new VaultClient(conf);
  Secret secret = vault.sys().lease().renew(leaseId);
  Assert.assertEquals(leaseId, secret.getLeaseId());
  Assert.assertEquals(60, secret.getLeaseDuration());
  Assert.assertEquals(true, secret.isRenewable());
}
 
Example #14
Source File: ProxyTest.java    From pmq with Apache License 2.0 5 votes vote down vote up
private void initServer(boolean flag) {
	if (mockRegistryServer != null) {
		mockRegistryServer.stop();
	}
	mockRegistryServer = startClientAndServer(flag ? port : port + 1);
	new MockServerClient("localhost", flag ? port : port + 1).when(request().withMethod("GET").withPath("/test/hs"))
			.respond(response().withStatusCode(200).withBody("{}"));

	new MockServerClient("localhost", flag ? port : port + 1)
			.when(request().withMethod("POST").withPath("/test/proxy"))
			.respond(response().withStatusCode(200).withBody("{}"));

}
 
Example #15
Source File: AvroSchemaHelperIT.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void registerSchema() throws Exception {
  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
          request()
              .withHeader(header("Content-Type", "application/vnd.schemaregistry.v1+json"))
              .withMethod("POST")
              .withPath("/subjects/topic1-value/versions"),
          exactly(1)
      )
      .respond(
          response()
              .withStatusCode(OK_200.code())
              .withHeader(contentJson)
              .withBody("{\"id\":1}")
      );

  AvroSchemaHelper helper = new AvroSchemaHelper(getSettings(address, DestinationAvroSchemaSource.INLINE, true));

  final String schemaString = getBody("schema-registry/schema_1.json");

  Schema schema = new Schema.Parser()
      .setValidate(true)
      .setValidateDefaults(true)
      .parse(schemaString);

  assertEquals(1, helper.registerSchema(schema, "topic1-value"));
}
 
Example #16
Source File: AvroSchemaHelperIT.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
  public void loadFromRegistry() throws Exception {
    new MockServerClient(localhost, mockServerRule.getPort())
        .when(
            request()
                .withMethod("GET")
                .withPath("/schemas/ids/1"),
            exactly(1)
        )
        .respond(
            response()
                .withStatusCode(OK_200.code())
                .withHeader(contentJson)
                .withBody(getBody("schema-registry/schema_1_resp.json"))
      );

    AvroSchemaHelper helper = new AvroSchemaHelper(getSettings(address, OriginAvroSchemaSource.REGISTRY, false));

    Schema schema = new Schema.Parser()
        .setValidate(true)
        .setValidateDefaults(true)
        .parse(getBody("schema-registry/schema_1.json"));

    assertEquals(schema, helper.loadFromRegistry(1));

    Map<String, Object> expectedDefaultValues = new HashMap<>();
    expectedDefaultValues.put("TestRecord.a", "");
    expectedDefaultValues.put("TestRecord.b", 0L);
    expectedDefaultValues.put("TestRecord.c", false);

    assertEquals(expectedDefaultValues, AvroSchemaHelper.getDefaultValues(schema));
}
 
Example #17
Source File: BotsTest.java    From geoportal-server-harvester with Apache License 2.0 5 votes vote down vote up
@Before
public void setupClass() throws IOException {
  client = new MockServerClient("localhost", 5000);
  client.when(
                  request()
                  .withMethod("GET")
                  .withPath("/robots.txt")
          )
          .respond(
                  response()
                  .withStatusCode(200)
                  .withBody(readAndClose(getClass().getResourceAsStream("/robots.txt")))
          );
}
 
Example #18
Source File: AvroSchemaHelperIT.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@Test
public void loadFromRegistryBySchemaId() throws Exception {
  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
          request()
              .withHeader(header("Content-Type", "application/vnd.schemaregistry.v1+json"))
              .withMethod("GET")
              .withPath("/schemas/ids/1"),
          exactly(1)
      )
      .respond(
          response()
              .withStatusCode(OK_200.code())
              .withHeader(contentJson)
              .withBody(getBody("schema-registry/schema_1_resp.json"))
      );

  AvroSchemaHelper helper = new AvroSchemaHelper(getSettings(address, OriginAvroSchemaSource.REGISTRY, false));

  final String schemaString = getBody("schema-registry/schema_1.json");

  Schema schema = new Schema.Parser()
      .setValidate(true)
      .setValidateDefaults(true)
      .parse(schemaString);

  assertEquals(schema, helper.loadFromRegistry(null, 1));
}
 
Example #19
Source File: PageHeaderIteratorTests.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Tests that a PageHeaderIterator correctly retrieves ETag headers for 3 pages from
 * a mocked server that conform to GitHub API's pagination specifications and terminates afterwards.
 *
 * @throws NoSuchElementException
 */
@Test
public void testHeaderIterator() throws NoSuchElementException, IOException {
    MockServerClient mockServer = ClientAndServer.startClientAndServer(8888);

    HttpRequest page1Request = createMockServerPagedHeaderRequest(1);
    List<Header> page1Headers = TestUtils.parseHeaderRecord(
            TestUtils.readFileFromResource(this, "tests/PagedHeadersSample/page1-header.txt"));
    String page1Etag = "aaf65fc6b10d5afbdc9cd0aa6e6ada4c";

    HttpRequest page2Request = createMockServerPagedHeaderRequest(2);
    List<Header> page2Headers = TestUtils.parseHeaderRecord(
            TestUtils.readFileFromResource(this, "tests/PagedHeadersSample/page2-header.txt"));
    String page2Etag = "731501e0f7d9816305782bc4c3f70d9f";

    HttpRequest page3Request = createMockServerPagedHeaderRequest(3);
    List<Header> page3Headers = TestUtils.parseHeaderRecord(
            TestUtils.readFileFromResource(this, "tests/PagedHeadersSample/page3-header.txt")
    );
    String page3Etag = "a6f367d674155d6fbbacbc2fca04917b";

    setUpHeadRequestOnMockServer(mockServer, page1Request, page1Headers);
    setUpHeadRequestOnMockServer(mockServer, page2Request, page2Headers);
    setUpHeadRequestOnMockServer(mockServer, page3Request, page3Headers);

    PagedRequest<Milestone> request = new PagedRequest<>();
    Map<String, String> params = new HashMap<>();
    params.put("state", "all");

    GitHubClientEx client = new GitHubClientEx("localhost", 8888, "http");

    String path = SEGMENT_REPOS + "/hubturbo/hubturbo" + SEGMENT_PULLS;
    request.setUri(path);
    request.setResponseContentType(CONTENT_TYPE_JSON);
    request.setParams(params);

    PageHeaderIterator iter = new PageHeaderIterator(request, client, "ETag");
    assertEquals(page1Etag, Utility.stripQuotes(iter.next()));
    assertEquals(page2Etag, Utility.stripQuotes(iter.next()));
    assertEquals(page3Etag, Utility.stripQuotes(iter.next()));
    assertFalse(iter.hasNext());

    mockServer.stop();
}
 
Example #20
Source File: ArquillianTest.java    From kubernetes-integration-test with Apache License 2.0 4 votes vote down vote up
@Before
public void before() throws Exception{
    if (!beforeDone){

        log.info("Before is running. oc client: {}",oc.getOpenshiftUrl());

        // Prepare database;
        // Run mysql client in container with oc cli tool
        // oc exec waits for the command to finish
        //Runtime rt = Runtime.getRuntime();
        //Process mysql = rt.exec("oc exec -i -n "+session.getNamespace()+" mariadb -- /opt/rh/rh-mariadb102/root/usr/bin/mysql -u myuser -pmypassword -h 127.0.0.1 testdb");
        //IOUtils.copy(this.getClass().getClassLoader().getResourceAsStream("sql/sql-load.sql"),mysql.getOutputStream() );
        //mysql.getOutputStream().close();
        //log.info("waitFor: {}",mysql.waitFor());
        //log.info("output: {}", IOUtils.toString(mysql.getInputStream()));
        //log.info("error: {}", IOUtils.toString(mysql.getErrorStream()));

        // Prepare database
        loadSql();


        //Prepare MockServer response for test
        log.info("mockserver URL: {}",mockserver);
        int port = mockserver.getPort() == -1 ? 80 : mockserver.getPort();
        log.info("mockserver {} {}",mockserver.getHost(),port);
        //We could use any http client to call the MockServer expectation api, but this java client is nicer
        MockServerClient mockServerClient = new MockServerClient(mockserver.getHost(),port);
        mockServerClient
                .when(
                        request()
                                .withMethod("GET")
                                .withPath("/v1/address/email/[email protected]")
                )
                .respond(
                        response()
                                .withBody("{\n" +
                                        "\"state\": \"Test State\",\n" +
                                        "\"city\": \"Test City\",\n" +
                                        "\"address\": \"1 Test St\",\n" +
                                        "\"zip\": \"T001\"\n" +
                                        "}\n")
                );

        beforeDone=true;
    }
}
 
Example #21
Source File: GitLabMessagePublisherTest.java    From gitlab-plugin with GNU General Public License v2.0 4 votes vote down vote up
@Before
public void setup() {
    listener = new StreamBuildListener(jenkins.createTaskListener().getLogger(), Charset.defaultCharset());
    mockServerClient = new MockServerClient("localhost", mockServer.getPort());
}
 
Example #22
Source File: GitLabCommitStatusPublisherTest.java    From gitlab-plugin with GNU General Public License v2.0 4 votes vote down vote up
@Before
public void setup() {
    listener = new StreamBuildListener(jenkins.createTaskListener().getLogger(), Charset.defaultCharset());
    mockServerClient = new MockServerClient("localhost", mockServer.getPort());
}
 
Example #23
Source File: GitLabAcceptMergeRequestPublisherTest.java    From gitlab-plugin with GNU General Public License v2.0 4 votes vote down vote up
@Before
public void setup() {
    listener = new StreamBuildListener(jenkins.createTaskListener().getLogger(), Charset.defaultCharset());
    mockServerClient = new MockServerClient("localhost", mockServer.getPort());
}
 
Example #24
Source File: GitLabVotePublisherTest.java    From gitlab-plugin with GNU General Public License v2.0 4 votes vote down vote up
@Before
public void setup() {
    listener = new StreamBuildListener(jenkins.createTaskListener().getLogger(), Charset.defaultCharset());
    mockServerClient = new MockServerClient("localhost", mockServer.getPort());
    mockUser(1, "jenkins");
}
 
Example #25
Source File: PageHeaderIteratorTests.java    From HubTurbo with GNU Lesser General Public License v3.0 4 votes vote down vote up
private void setUpHeadRequestOnMockServer(MockServerClient mockServer, HttpRequest request, List<Header> headers) {
    mockServer
            .when(request)
            .respond(response().withHeaders(headers));
}
 
Example #26
Source File: AvroSchemaHelperIT.java    From datacollector with Apache License 2.0 4 votes vote down vote up
@Test
public void loadFromRegistryBySubject() throws Exception {
  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
          request()
              .withHeader(header("Content-Type", "application/vnd.schemaregistry.v1+json"))
              .withMethod("GET")
              .withPath("/schemas/ids/1"),
          exactly(1)
      )
      .respond(
          response()
              .withStatusCode(OK_200.code())
              .withHeader(contentJson)
              .withBody(getBody("schema-registry/schema_1_resp.json"))
      );

  new MockServerClient(localhost, mockServerRule.getPort())
      .when(
          request()
              .withHeader(header("Content-Type", "application/vnd.schemaregistry.v1+json"))
              .withMethod("GET")
              .withPath("/subjects/topic1-value/versions/latest"),
          exactly(1)
      )
      .respond(
          response()
              .withStatusCode(OK_200.code())
              .withHeader(contentJson)
              .withBody(getBody("schema-registry/schema_1_subject_resp.json"))
      );

  AvroSchemaHelper helper = new AvroSchemaHelper(getSettings(address, OriginAvroSchemaSource.REGISTRY, false));

  final String schemaString = getBody("schema-registry/schema_1.json");

  Schema schema = new Schema.Parser()
      .setValidate(true)
      .setValidateDefaults(true)
      .parse(schemaString);

  assertEquals(schema, helper.loadFromRegistry("topic1-value", 0));
}
 
Example #27
Source File: MockServerUtils.java    From pagerduty-client with MIT License 3 votes vote down vote up
/**
 * Prepare the mock server to receive the given incident and reply with an error eventResult
 * @param mockServerClient mock client to configure the incident/event upon
 * @param incident expected to be received in the mock server from the client
 * @param eventResult to be returned by the mock server
 * @throws JsonProcessingException
 */
public static void prepareMockServerToReceiveIncidentAndReplyWithWithErrorResponse(MockServerClient mockServerClient, Incident incident, EventResult eventResult) throws JsonProcessingException {
    String responseBody = "{\"status\":\"" + eventResult.getStatus()
            + "\",\"message\":\"" + eventResult.getMessage()
            + "\",\"errors\":" + eventResult.getErrors() + "}";
    prepareMockServer(mockServerClient, incident, HttpStatus.SC_BAD_REQUEST, responseBody);
}
 
Example #28
Source File: AbstractFunctionalTest.java    From vertx-s3-client with Apache License 2.0 3 votes vote down vote up
protected static MockServerClient getMockServerClient() {
    return mockServerClient;
}
 
Example #29
Source File: ConverterTest.java    From moshi-jsonapi with MIT License 3 votes vote down vote up
private MockServerClient server() {
    return mockServerRule.getClient();
}
 
Example #30
Source File: AbstractFunctionalTest.java    From vertx-rest-client with Apache License 2.0 3 votes vote down vote up
protected static MockServerClient getMockServerClient() {
    return mockServerClient;
}