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));
}
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)));
}
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)));
}
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");
}
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());
}
Aggregations