use of org.folio.rest.acq.model.finance.CompositeFund in project mod-invoice by folio-org.
the class MockServer method handleFundById.
private void handleFundById(RoutingContext ctx) {
logger.info("handleFund got: GET " + ctx.request().path());
String id = ctx.request().getParam(AbstractHelper.ID);
logger.info("id: " + id);
if (ID_DOES_NOT_EXIST.equals(id)) {
serverResponse(ctx, 404, APPLICATION_JSON, Response.Status.NOT_FOUND.getReasonPhrase());
} else if (ID_FOR_INTERNAL_SERVER_ERROR.equals(id)) {
serverResponse(ctx, 500, APPLICATION_JSON, INTERNAL_SERVER_ERROR.getReasonPhrase());
} else {
Fund fund = new Fund().withId(UUID.randomUUID().toString()).withLedgerId(UUID.randomUUID().toString()).withCode("TEST").withName("TEST");
List<CompositeFund> funds = getMockEntries(FUNDS, Fund.class).map(funds1 -> funds1.stream().map(fund1 -> new CompositeFund().withFund(fund1)).collect(toList())).orElse(Collections.singletonList(new CompositeFund().withFund(fund)));
addServerRqRsData(HttpMethod.GET, FUNDS, JsonObject.mapFrom(funds.get(0)));
serverResponse(ctx, 200, APPLICATION_JSON, JsonObject.mapFrom(funds.get(0)).encodePrettily());
}
}
use of org.folio.rest.acq.model.finance.CompositeFund in project mod-orders by folio-org.
the class FundServiceTest method testShouldRetrieveFundById.
@Test
void testShouldRetrieveFundById() {
// Given
String ledgerId = UUID.randomUUID().toString();
String fundId = UUID.randomUUID().toString();
CompositeFund compositeFund = new CompositeFund().withFund(new Fund().withId(fundId).withLedgerId(ledgerId));
doReturn(completedFuture(compositeFund)).when(restClient).get(any(), eq(requestContext), eq(CompositeFund.class));
// When
Fund actFund = fundService.retrieveFundById(fundId, requestContext).join();
// Then
assertThat(actFund, equalTo(compositeFund.getFund()));
ArgumentCaptor<RequestEntry> argumentCaptor = ArgumentCaptor.forClass(RequestEntry.class);
verify(restClient).get(argumentCaptor.capture(), eq(requestContext), eq(CompositeFund.class));
RequestEntry requestEntry = argumentCaptor.getValue();
assertEquals("/finance/funds/" + fundId, requestEntry.buildEndpoint());
}
Aggregations