use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class TransactionLoadHoldingsImplTest method shouldSendSaveHoldingsEventForEachLoadedPage.
@Test
public void shouldSendSaveHoldingsEventForEachLoadedPage(TestContext context) throws IOException, URISyntaxException {
mockEmptyTransactionList();
mockGet(new EqualToPattern(getStatusEndpoint()), RMAPI_RESPONSE_TRANSACTION_STATUS_COMPLETED);
mockGet(new RegexPattern(getHoldingsEndpoint()), RMAPI_RESPONSE_HOLDINGS);
List<HoldingsMessage> messages = new ArrayList<>();
Async async = context.async(EXPECTED_LOADED_PAGES);
interceptor = interceptAndStop(HOLDINGS_SERVICE_ADDRESS, SAVE_HOLDINGS_ACTION, message -> {
messages.add(((JsonObject) message.body()).getJsonObject("holdings").mapTo(HoldingsMessage.class));
async.countDown();
});
vertx.eventBus().addOutboundInterceptor(interceptor);
LoadServiceFacade proxy = LoadServiceFacade.createProxy(vertx, LOAD_FACADE_ADDRESS);
LoadHoldingsMessage message = new LoadHoldingsMessage(this.configuration, STUB_CREDENTIALS_ID, STUB_TENANT, 5001, 2, TRANSACTION_ID, null);
proxy.loadHoldings(message);
async.await(TIMEOUT);
assertEquals(2, messages.size());
assertEquals(STUB_HOLDINGS_TITLE, messages.get(0).getHoldingList().get(0).getPublicationTitle());
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class DefaultLoadHoldingsImplTest method runPostHoldingsWithMocks.
private void runPostHoldingsWithMocks(TestContext context) throws IOException, URISyntaxException {
Async async = context.async();
handleStatusChange(COMPLETED, holdingsStatusRepository, o -> async.complete());
mockGet(new EqualToPattern(RMAPI_HOLDINGS_STATUS_URL), RMAPI_RESPONSE_HOLDINGS_STATUS_COMPLETED);
mockPostHoldings();
mockGet(new RegexPattern(RMAPI_POST_HOLDINGS_URL), RMAPI_RESPONSE_HOLDINGS);
postWithStatus(HOLDINGS_LOAD_BY_ID_URL, "", SC_NO_CONTENT, STUB_TOKEN_HEADER);
async.await(TIMEOUT);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsProxyTypesImplTest method shouldReturnProxyTypesWhenUserAssignedToKbCredentials.
@Test
public void shouldReturnProxyTypesWhenUserAssignedToKbCredentials() throws IOException, URISyntaxException, JSONException {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
saveAssignedUser(JOHN_ID, STUB_CREDENTIALS_ID, vertx);
mockGet(new RegexPattern(RMAPI_PROXIES_URL), "responses/rmapi/proxytypes/get-proxy-types-response.json");
String actual = getWithStatus(EHOLDINGS_PROXY_TYPES_URL, SC_OK, JOHN_TOKEN_HEADER).asString();
String expected = readFile("responses/kb-ebsco/proxytypes/get-proxy-types-response.json");
JSONAssert.assertEquals(expected, actual, true);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsProxyTypesImplTest method shouldReturnEmptyCollection.
@Test
public void shouldReturnEmptyCollection() throws IOException, URISyntaxException, JSONException {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
mockGet(new RegexPattern(RMAPI_PROXIES_URL), "responses/rmapi/proxytypes/get-proxy-types-response.json");
String resourcePath = String.format(EHOLDINGS_PROXY_TYPES_BY_CREDENTIALS_ID_URL, STUB_CREDENTIALS_ID);
String actual = getWithOk(resourcePath).asString();
String expected = readFile("responses/kb-ebsco/proxytypes/get-proxy-types-response.json");
JSONAssert.assertEquals(expected, actual, true);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsProxyTypesImplTest method shouldReturnProxyTypesWhenOneCredentialsExistsAndUserNotAssigned.
@Test
public void shouldReturnProxyTypesWhenOneCredentialsExistsAndUserNotAssigned() throws IOException, URISyntaxException, JSONException {
saveKbCredentials(STUB_CREDENTIALS_ID, getWiremockUrl(), STUB_CREDENTIALS_NAME, STUB_API_KEY, STUB_CUSTOMER_ID, vertx);
mockGet(new RegexPattern(RMAPI_PROXIES_URL), "responses/rmapi/proxytypes/get-proxy-types-response.json");
String actual = getWithStatus(EHOLDINGS_PROXY_TYPES_URL, SC_OK, JOHN_TOKEN_HEADER).asString();
String expected = readFile("responses/kb-ebsco/proxytypes/get-proxy-types-response.json");
JSONAssert.assertEquals(expected, actual, true);
}
Aggregations