use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsRootProxyImplTest method shouldReturn400WhenInvalidProxyIDAndRMAPIErrorOnPut.
@Test
public void shouldReturn400WhenInvalidProxyIDAndRMAPIErrorOnPut() throws IOException, URISyntaxException {
String stubGetResponseFile = "responses/rmapi/proxiescustomlabels/get-updated-response.json";
String stubPutResponseFile = "responses/rmapi/proxiescustomlabels/put-400-error-response.json";
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
mockGet(new EqualToPattern(RMAPI_ROOT_PROXY_CUSTOM_LABELS_URL), stubGetResponseFile);
stubFor(put(new UrlPathPattern(new EqualToPattern(RMAPI_ROOT_PROXY_CUSTOM_LABELS_URL), false)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(stubPutResponseFile)).withStatus(SC_BAD_REQUEST)));
final String path = String.format(EHOLDINGS_ROOT_PROXY_BY_CREDENTIALS_ID_URL, STUB_CREDENTIALS_ID);
JsonapiError error = putWithStatus(path, readFile("requests/kb-ebsco/put-root-proxy.json"), SC_BAD_REQUEST).as(JsonapiError.class);
assertErrorContainsTitle(error, "Invalid Proxy ID");
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsRootProxyImplTest method shouldReturnUpdatedProxyOnSuccessfulPut.
@Test
public void shouldReturnUpdatedProxyOnSuccessfulPut() throws IOException, URISyntaxException, JSONException {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
String stubResponseFile = "responses/rmapi/proxiescustomlabels/get-updated-response.json";
mockGet(new RegexPattern(RMAPI_ROOT_PROXY_CUSTOM_LABELS_URL), stubResponseFile);
mockPut(new RegexPattern(RMAPI_ROOT_PROXY_CUSTOM_LABELS_URL), SC_NO_CONTENT);
String expected = readFile("responses/kb-ebsco/root-proxy/put-root-proxy-response-updated.json");
final String path = String.format(EHOLDINGS_ROOT_PROXY_BY_CREDENTIALS_ID_URL, STUB_CREDENTIALS_ID);
String actual = putWithOk(path, readFile("requests/kb-ebsco/put-root-proxy.json")).asString();
JSONAssert.assertEquals(expected, actual, true);
verify(1, putRequestedFor(new UrlPathPattern(new RegexPattern(RMAPI_ROOT_PROXY_CUSTOM_LABELS_URL), true)).withRequestBody(equalToJson(readFile("requests/rmapi/proxiescustomlabels/put-root-proxy.json"))));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsAccessTypesImplTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
stubFor(get(new UrlPathPattern(new EqualToPattern("/users/" + USER_8), false)).willReturn(new ResponseDefinitionBuilder().withStatus(200).withBody(readFile("responses/userlookup/mock_user_response_200.json"))));
stubFor(get(new UrlPathPattern(new EqualToPattern("/users/" + USER_9), false)).willReturn(new ResponseDefinitionBuilder().withStatus(200).withBody(readFile("responses/userlookup/mock_user_response_2_200.json"))));
stubFor(get(new UrlPathPattern(new EqualToPattern("/users/" + USER_2), false)).willReturn(new ResponseDefinitionBuilder().withStatus(404)));
stubFor(get(new UrlPathPattern(new EqualToPattern("/users/" + USER_3), false)).willReturn(new ResponseDefinitionBuilder().withStatus(403)));
credentialsId = saveKbCredentials(STUB_API_URL, STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
setUpTestUsers();
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsPackagesTest method shouldReturn200OnPostPackageWithExistedAccessType.
@Test
public void shouldReturn200OnPostPackageWithExistedAccessType() throws URISyntaxException, IOException {
String accessTypeId = insertAccessType(testData(configuration.getId()).get(0), vertx);
String packagePostRMAPIRequestFile = "requests/rmapi/packages/post-package.json";
String requestBody = String.format(readFile("requests/kb-ebsco/package/post-package-with-access-type-request.json"), accessTypeId);
Package createdPackage = sendPost(requestBody).as(Package.class);
assertTrue(Objects.isNull(createdPackage.getData().getAttributes().getTags()));
EqualToJsonPattern postBodyPattern = new EqualToJsonPattern(readFile(packagePostRMAPIRequestFile), false, true);
verify(1, postRequestedFor(new UrlPathPattern(new EqualToPattern(PACKAGES_STUB_URL), false)).withRequestBody(postBodyPattern));
List<AccessTypeMapping> accessTypeMappingsInDB = getAccessTypeMappings(vertx);
assertEquals(1, accessTypeMappingsInDB.size());
assertEqualsUUID(accessTypeId, accessTypeMappingsInDB.get(0).getAccessTypeId());
assertEquals(PACKAGE, accessTypeMappingsInDB.get(0).getRecordType());
assertNotNull(createdPackage.getIncluded());
assertEquals(accessTypeId, createdPackage.getData().getRelationships().getAccessType().getData().getId());
assertEquals(accessTypeId, ((LinkedHashMap<?, ?>) createdPackage.getIncluded().get(0)).get("id"));
}
use of com.github.tomakehurst.wiremock.matching.UrlPathPattern in project mod-kb-ebsco-java by folio-org.
the class EholdingsTitlesTest method shouldReturnTitleTagsWhenValidId.
@Test
public void shouldReturnTitleTagsWhenValidId() throws IOException, URISyntaxException {
String stubResponseFile = "responses/rmapi/titles/get-title-by-id-response.json";
saveTag(vertx, STUB_MANAGED_TITLE_ID, RecordType.TITLE, STUB_TAG_VALUE);
stubFor(get(new UrlPathPattern(new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/titles.*"), true)).willReturn(new ResponseDefinitionBuilder().withBody(readFile(stubResponseFile))));
Title actualResponse = getWithOk(EHOLDINGS_TITLES_PATH + "/" + STUB_TITLE_ID, STUB_TOKEN_HEADER).as(Title.class);
assertTrue(actualResponse.getData().getAttributes().getTags().getTagList().contains(STUB_TAG_VALUE));
}
Aggregations