use of org.folio.holdingsiq.model.Configuration in project mod-kb-ebsco-java by folio-org.
the class DefaultLoadServiceFacadeTest method shouldNotCreateSnapshotIfItWasRecentlyCreated.
@Test
public void shouldNotCreateSnapshotIfItWasRecentlyCreated(TestContext context) throws IOException, URISyntaxException {
Async async = context.async();
String now = HOLDINGS_STATUS_TIME_FORMATTER.format(LocalDateTime.now(ZoneOffset.UTC));
HoldingsLoadStatus status = readJsonFile("responses/rmapi/holdings/status/get-status-completed.json", HoldingsLoadStatus.class).toBuilder().created(now).build();
mockGetWithBody(new EqualToPattern(RMAPI_HOLDINGS_STATUS_URL), Json.encode(status));
mockPostHoldings();
interceptor = interceptAndStop(HOLDINGS_SERVICE_ADDRESS, SNAPSHOT_CREATED_ACTION, message -> async.complete());
vertx.eventBus().addOutboundInterceptor(interceptor);
loadServiceFacade.createSnapshot(new ConfigurationMessage(configuration, STUB_CREDENTIALS_ID, STUB_TENANT));
async.await(TIMEOUT);
WireMock.verify(0, postRequestedFor(new UrlPathPattern(new EqualToPattern(RMAPI_POST_HOLDINGS_URL), false)));
}
use of org.folio.holdingsiq.model.Configuration 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 org.folio.holdingsiq.model.Configuration 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 org.folio.holdingsiq.model.Configuration in project mod-kb-ebsco-java by folio-org.
the class RMAPITemplateContextBuilder method build.
public RMAPITemplateContext build() {
String tenant = okapiData.getTenant();
Configuration configuration = converter.convert(credentials);
final HoldingsIQService holdingsService = new HoldingsIQServiceImpl(configuration, vertx);
final TitlesServiceImpl titlesService = new TitlesServiceImpl(configuration, vertx, okapiData.getTenant(), titleCache);
final ProvidersServiceImpl providersService = new ProvidersServiceImpl(configuration, vertx, tenant, holdingsService, vendorCache);
final PackageServiceImpl packagesService = new PackageServiceImpl(configuration, vertx, tenant, providersService, titlesService, packageCache, searchProperties);
final ResourcesServiceImpl resourcesService = new ResourcesServiceImpl(configuration, vertx, tenant, providersService, packagesService, resourceCache);
final LoadService loadService = new LoadServiceImpl(configuration, vertx);
providersService.setPackagesService(packagesService);
return RMAPITemplateContext.builder().configuration(configuration).okapiData(okapiData).credentialsId(credentials.getId()).credentialsName(credentials.getAttributes().getName()).holdingsService(holdingsService).packagesService(packagesService).providersService(providersService).resourcesService(resourcesService).titlesService(titlesService).loadingService(loadService).build();
}
use of org.folio.holdingsiq.model.Configuration in project mod-kb-ebsco-java by folio-org.
the class ProviderServiceImplTest method shouldReturnCachedProviderOnSecondRequest.
@Test
public void shouldReturnCachedProviderOnSecondRequest() throws IOException, URISyntaxException {
RegexPattern getVendorPattern = new RegexPattern("/rm/rmaccounts/" + STUB_CUSTOMER_ID + "/vendors/" + STUB_VENDOR_ID);
Configuration configuration = Configuration.builder().url("http://127.0.0.1:" + userMockServer.port()).customerId(STUB_CUSTOMER_ID).apiKey("API KEY").build();
ProvidersServiceImpl service = new ProvidersServiceImpl(configuration, Vertx.vertx(), STUB_TENANT, null, new VertxCache<>(Vertx.vertx(), 60, "vendorCache"));
mockGet(getVendorPattern, VENDOR_STUB_FILE);
service.retrieveProvider(STUB_VENDOR_ID, null, true).join();
service.retrieveProvider(STUB_VENDOR_ID, null, true).join();
verify(1, getRequestedFor(new UrlPattern(getVendorPattern, true)));
}
Aggregations