use of org.folio.rest.core.models.RequestEntry in project mod-invoice by folio-org.
the class OrderService method getOrderInvoiceRelationshipByOrderIdAndInvoiceId.
public CompletableFuture<OrderInvoiceRelationshipCollection> getOrderInvoiceRelationshipByOrderIdAndInvoiceId(String orderId, String invoiceId, RequestContext requestContext) {
String query = String.format(ORDER_INVOICE_RELATIONSHIP_QUERY, orderId, invoiceId);
RequestEntry requestEntry = new RequestEntry(ORDER_INVOICE_RELATIONSHIPS_ENDPOINT).withQuery(query).withOffset(0).withLimit(100);
return restClient.get(requestEntry, requestContext, OrderInvoiceRelationshipCollection.class);
}
use of org.folio.rest.core.models.RequestEntry in project mod-invoice by folio-org.
the class RestClientTest method testPostShouldCreateEntity.
@Test
public void testPostShouldCreateEntity() throws Exception {
RestClient restClient = Mockito.spy(new RestClient());
String uuid = UUID.randomUUID().toString();
Transaction expTransaction = new Transaction().withId(uuid);
Response response = new Response();
response.setBody(JsonObject.mapFrom(expTransaction));
response.setCode(201);
RequestEntry requestEntry = new RequestEntry(resourcesPath(FINANCE_STORAGE_TRANSACTIONS));
doReturn(httpClient).when(restClient).getHttpClient(okapiHeaders);
doReturn(completedFuture(response)).when(httpClient).request(eq(HttpMethod.POST), any(), eq(resourcesPath(FINANCE_STORAGE_TRANSACTIONS)), eq(okapiHeaders));
Transaction actTransaction = restClient.post(requestEntry, expTransaction, requestContext, Transaction.class).join();
assertThat(actTransaction, equalTo(expTransaction));
}
use of org.folio.rest.core.models.RequestEntry in project mod-invoice by folio-org.
the class RestClientTest method testDeleteShouldCreateEntity.
@Test
public void testDeleteShouldCreateEntity() throws Exception {
RestClient restClient = Mockito.spy(new RestClient());
String uuid = UUID.randomUUID().toString();
Response response = new Response();
response.setCode(204);
doReturn(httpClient).when(restClient).getHttpClient(okapiHeaders);
String endpoint = resourcesPath(FINANCE_STORAGE_TRANSACTIONS) + "/" + uuid;
RequestEntry requestEntry = new RequestEntry(resourcesPath(FINANCE_STORAGE_TRANSACTIONS) + "/{id}").withId(uuid);
doReturn(completedFuture(response)).when(httpClient).request(eq(HttpMethod.DELETE), eq(endpoint), eq(okapiHeaders));
restClient.delete(requestEntry, requestContext).get();
verify(httpClient).request(eq(HttpMethod.DELETE), eq(endpoint), eq(okapiHeaders));
}
use of org.folio.rest.core.models.RequestEntry in project mod-invoice by folio-org.
the class RestClientTest method testGetShouldSearchById.
@Test
public void testGetShouldSearchById() throws Exception {
RestClient restClient = Mockito.spy(new RestClient());
String uuid = UUID.randomUUID().toString();
String endpoint = resourcesPath(FINANCE_STORAGE_TRANSACTIONS) + "/" + uuid;
Transaction expTransaction = new Transaction().withId(uuid);
Response response = new Response();
response.setBody(JsonObject.mapFrom(expTransaction));
response.setCode(200);
doReturn(httpClient).when(restClient).getHttpClient(okapiHeaders);
doReturn(completedFuture(response)).when(httpClient).request(HttpMethod.GET, endpoint, okapiHeaders);
RequestEntry requestEntry = new RequestEntry(resourcesPath(FINANCE_STORAGE_TRANSACTIONS) + "/{id}").withId(uuid);
Transaction actTransaction = restClient.get(requestEntry, requestContext, Transaction.class).join();
assertThat(actTransaction, equalTo(expTransaction));
}
use of org.folio.rest.core.models.RequestEntry in project mod-invoice by folio-org.
the class ConfigurationService method loadConfiguration.
public CompletableFuture<JsonObject> loadConfiguration(String moduleConfig, RequestContext requestContext) {
String query = String.format(CONFIG_QUERY, moduleConfig);
RequestEntry requestEntry = new RequestEntry(CONFIGURATION_ENDPOINT).withQuery(query).withOffset(0).withLimit(Integer.MAX_VALUE);
logger.info("GET request: {}", query);
return restClient.get(requestEntry, requestContext, Configs.class).thenApply(configs -> {
if (logger.isDebugEnabled()) {
logger.debug("The response from mod-configuration: {}", JsonObject.mapFrom(configs).encodePrettily());
}
JsonObject config = new JsonObject();
configs.getConfigs().forEach(entry -> config.put(entry.getConfigName(), entry.getValue()));
return config;
});
}
Aggregations