use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class EHoldingsRootProxyImplTest method shouldReturnRootProxyWhenUserAssignedToKbCredentials.
@Test
public void shouldReturnRootProxyWhenUserAssignedToKbCredentials() 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_ROOT_PROXY_CUSTOM_LABELS_URL), RMAPI_ROOT_PROXY_CUSTOM_LABELS_RESPONSE);
String actual = getWithStatus(EHOLDINGS_ROOT_PROXY_URL, SC_OK, JOHN_TOKEN_HEADER).asString();
String expected = readFile(KB_EBSCO_GET_ROOT_PROXY_RESPONSE);
JSONAssert.assertEquals(expected, actual, true);
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class UsersLookUpServiceTest method shouldReturn200WhenUserIdIsValid.
@Test
public void shouldReturn200WhenUserIdIsValid(TestContext context) throws IOException, URISyntaxException {
final String stubUserId = "88888888-8888-4888-8888-888888888888";
final String stubUserIdEndpoint = GET_USER_ENDPOINT + stubUserId;
Async async = context.async();
OKAPI_HEADERS.put(XOkapiHeaders.TENANT, STUB_TENANT);
OKAPI_HEADERS.put(XOkapiHeaders.URL, getWiremockUrl());
OKAPI_HEADERS.put(XOkapiHeaders.USER_ID, stubUserId);
stubFor(get(new UrlPathPattern(new RegexPattern(stubUserIdEndpoint), true)).willReturn(new ResponseDefinitionBuilder().withBody(TestUtil.readFile(USER_INFO_STUB_FILE))));
CompletableFuture<User> info = usersLookUpService.lookUpUser(new OkapiParams(OKAPI_HEADERS));
info.thenCompose(userInfo -> {
context.assertNotNull(userInfo);
context.assertEquals("cedrick", userInfo.getUserName());
context.assertEquals("firstname_test", userInfo.getFirstName());
context.assertNull(userInfo.getMiddleName());
context.assertEquals("lastname_test", userInfo.getLastName());
async.complete();
return null;
}).exceptionally(throwable -> {
context.fail(throwable);
async.complete();
return null;
});
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class PackageServiceImplTest method shouldReturnCachedPackage.
@Test
public void shouldReturnCachedPackage() throws IOException, URISyntaxException {
RegexPattern getPackagePattern = new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/vendors/" + STUB_VENDOR_ID + "/packages/" + STUB_PACKAGE_ID);
Configuration configuration = Configuration.builder().url("http://127.0.0.1:" + userMockServer.port()).customerId(STUB_CUSTOMER_ID).apiKey("API KEY").build();
PackageServiceImpl service = new PackageServiceImpl(configuration, Vertx.vertx(), STUB_TENANT, null, null, new VertxCache<>(Vertx.vertx(), 60, "packageCache"), null);
mockGet(getPackagePattern, CUSTOM_PACKAGE_STUB_FILE);
PackageId packageId = PackageId.builder().packageIdPart(STUB_PACKAGE_ID).providerIdPart(STUB_VENDOR_ID).build();
service.retrievePackage(packageId, Collections.emptyList(), true).join();
service.retrievePackage(packageId, Collections.emptyList(), true).join();
verify(1, getRequestedFor(new UrlPattern(getPackagePattern, true)));
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class ResourceServiceImplTest method shouldReturnCachedResource.
@Test
public void shouldReturnCachedResource() throws IOException, URISyntaxException {
RegexPattern getResourcePattern = new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/vendors/" + STUB_VENDOR_ID + "/packages/" + STUB_PACKAGE_ID + "/titles/" + STUB_TITLE_ID);
Configuration configuration = Configuration.builder().url("http://127.0.0.1:" + userMockServer.port()).customerId(STUB_CUSTOMER_ID).apiKey("API KEY").build();
ResourcesServiceImpl service = new ResourcesServiceImpl(configuration, Vertx.vertx(), STUB_TENANT, null, null, new VertxCache<>(Vertx.vertx(), 60, "resourceCache"));
mockGet(getResourcePattern, CUSTOM_RESOURCE_STUB_FILE);
ResourceId resourceId = ResourceId.builder().packageIdPart(STUB_PACKAGE_ID).providerIdPart(STUB_VENDOR_ID).titleIdPart(STUB_TITLE_ID).build();
service.retrieveResource(resourceId, Collections.emptyList(), true).join();
service.retrieveResource(resourceId, Collections.emptyList(), true).join();
verify(1, getRequestedFor(new UrlPattern(getResourcePattern, true)));
}
use of com.github.tomakehurst.wiremock.matching.RegexPattern in project mod-kb-ebsco-java by folio-org.
the class TitleServiceImplTest method shouldNotUseCache.
@Test
public void shouldNotUseCache() throws IOException, URISyntaxException {
RegexPattern getTitlePattern = new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/titles/" + STUB_TITLE_ID);
TitlesServiceImpl service = new TitlesServiceImpl(configuration, Vertx.vertx(), STUB_TENANT, new VertxCache<>(Vertx.vertx(), 60, "titleCache"));
mockGet(getTitlePattern, TITLE_STUB_FILE);
service.retrieveTitle(STUB_TITLE_ID, false).join();
verify(1, getRequestedFor(new UrlPattern(getTitlePattern, true)));
}
Aggregations