Search in sources :

Example 11 with RegexPattern

use of com.github.tomakehurst.wiremock.matching.RegexPattern in project neow3j by neow3j.

the class NeoTokenTest method getCommittee.

@Test
public void getCommittee() throws IOException {
    String responseBody = loadFile("/responses/invokefunction_getcommittee.json");
    WireMock.stubFor(post(urlEqualTo("/")).withRequestBody(new RegexPattern("" + ".*\"method\":\"invokefunction\"" + ".*\"params\":" + ".*\"" + NEOTOKEN_SCRIPTHASH + "\"" + // function
    ".*\"getCommittee\".*")).willReturn(aResponse().withStatus(200).withBody(responseBody)));
    List<ECPublicKey> result = new NeoToken(neow).getCommittee();
    String expKeyHex = "02163946a133e3d2e0d987fb90cb01b060ed1780f1718e2da28edf13b965fd2b60";
    ECPublicKey expKey = new ECPublicKey(hexStringToByteArray(expKeyHex));
    assertThat(result, contains(expKey));
}
Also used : ECPublicKey(io.neow3j.crypto.ECKeyPair.ECPublicKey) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) Test(org.junit.Test)

Example 12 with RegexPattern

use of com.github.tomakehurst.wiremock.matching.RegexPattern in project neow3j by neow3j.

the class WalletTestHelper method setUpWireMockForCall.

public static void setUpWireMockForCall(String call, String responseFile, String param) throws IOException {
    String responseBody = loadFile("/responses/" + responseFile);
    WireMock.stubFor(WireMock.post(WireMock.urlEqualTo("/")).withRequestBody(new RegexPattern("" + ".*\"method\":\"" + call + "\".*" + ".*\"params\":.*" + ".*\"" + param + "\".*")).willReturn(WireMock.aResponse().withStatus(200).withBody(responseBody)));
}
Also used : RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern)

Example 13 with RegexPattern

use of com.github.tomakehurst.wiremock.matching.RegexPattern in project neow3j by neow3j.

the class WireMockTestHelper method setUpWireMockForBalanceOf.

public static void setUpWireMockForBalanceOf(String accountScriptHash, String responseFile) throws IOException {
    String responseBody = loadFile("/responses/" + responseFile);
    WireMock.stubFor(WireMock.post(WireMock.urlEqualTo("/")).withRequestBody(new RegexPattern("" + ".*\"method\":\"invokefunction\"" + ".*\"params\":.*\"balanceOf\".*" + ".*\"" + accountScriptHash + "\".*")).willReturn(WireMock.aResponse().withStatus(200).withBody(responseBody)));
}
Also used : RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern)

Example 14 with RegexPattern

use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.

the class EholdingsPackagesTest method shouldReturn422OnPutWhenUnselectNonCustomPackageIsHidden.

@Test
public void shouldReturn422OnPutWhenUnselectNonCustomPackageIsHidden() throws URISyntaxException, IOException {
    String putBody = readFile("requests/kb-ebsco/package/put-package-not-selected-non-empty-fields.json");
    mockGet(new RegexPattern(PACKAGE_BY_ID_URL), PACKAGE_STUB_FILE);
    JsonapiError error = putWithStatus(PACKAGES_PATH, putBody, SC_UNPROCESSABLE_ENTITY, CONTENT_TYPE_HEADER, STUB_TOKEN_HEADER).as(JsonapiError.class);
    verify(0, putRequestedFor(PACKAGE_URL_PATTERN));
    assertErrorContainsTitle(error, "Invalid visibilityData.isHidden");
}
Also used : RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) JsonapiError(org.folio.rest.jaxrs.model.JsonapiError) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 15 with RegexPattern

use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.

the class EholdingsPackagesTest method shouldReturnEmptyResponseWhenPackagesReturnedWithErrorOnSearchByTags.

@Test
public void shouldReturnEmptyResponseWhenPackagesReturnedWithErrorOnSearchByTags() {
    savePackage(buildDbPackage(FULL_PACKAGE_ID, configuration.getId(), STUB_PACKAGE_NAME), vertx);
    savePackage(buildDbPackage(FULL_PACKAGE_ID_2, configuration.getId(), STUB_PACKAGE_NAME_2), vertx);
    saveTag(vertx, FULL_PACKAGE_ID, PACKAGE, STUB_TAG_VALUE);
    saveTag(vertx, FULL_PACKAGE_ID_2, PACKAGE, STUB_TAG_VALUE);
    mockGet(new RegexPattern(".*vendors/.*/packages/.*"), HttpStatus.SC_INTERNAL_SERVER_ERROR);
    PackageCollection packageCollection = getWithOk(PACKAGES_ENDPOINT + "?filter[tags]=" + STUB_TAG_VALUE, STUB_TOKEN_HEADER).as(PackageCollection.class);
    List<PackageCollectionItem> packages = packageCollection.getData();
    assertEquals(2, (int) packageCollection.getMeta().getTotalResults());
    assertEquals(0, packages.size());
}
Also used : PackageCollectionItem(org.folio.rest.jaxrs.model.PackageCollectionItem) RegexPattern(com.github.tomakehurst.wiremock.matching.RegexPattern) PackageCollection(org.folio.rest.jaxrs.model.PackageCollection) Test(org.junit.Test)

Aggregations

RegexPattern (com.github.tomakehurst.wiremock.matching.RegexPattern)148 Test (org.junit.Test)119 UrlPathPattern (com.github.tomakehurst.wiremock.matching.UrlPathPattern)79 Matchers.containsString (org.hamcrest.Matchers.containsString)46 Async (io.vertx.ext.unit.Async)33 JsonapiError (org.folio.rest.jaxrs.model.JsonapiError)31 ResponseDefinitionBuilder (com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder)26 Before (org.junit.Before)22 JsonObject (io.vertx.core.json.JsonObject)18 MappingParameters (org.folio.processing.mapping.defaultmapper.processor.parameters.MappingParameters)16 HashMap (java.util.HashMap)13 EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)12 AbstractRestTest (org.folio.rest.impl.AbstractRestTest)12 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)10 TestContext (io.vertx.ext.unit.TestContext)10 WireMockConfiguration (com.github.tomakehurst.wiremock.core.WireMockConfiguration)9 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)9 IOException (java.io.IOException)9 ParsedRecord (org.folio.rest.jaxrs.model.ParsedRecord)9 RunWith (org.junit.runner.RunWith)9