use of org.folio.rest.acq.model.finance.ExpenseClassCollection in project mod-orders by folio-org.
the class MockServer method handleGetExpenseClasses.
private void handleGetExpenseClasses(RoutingContext ctx) {
logger.info("handleGetExpenseClasses: " + ctx.request().path());
try {
ExpenseClassCollection expenseClassCollection = new JsonObject(getMockData(EXPENSE_CLASSES_MOCK_DATA_PATH)).mapTo(ExpenseClassCollection.class);
JsonObject entries = JsonObject.mapFrom(expenseClassCollection);
serverResponse(ctx, 200, APPLICATION_JSON, entries.encodePrettily());
} catch (IOException exception) {
serverResponse(ctx, 500, APPLICATION_JSON, INTERNAL_SERVER_ERROR.getReasonPhrase());
}
}
use of org.folio.rest.acq.model.finance.ExpenseClassCollection in project mod-invoice by folio-org.
the class MockServer method handleExpenseClasses.
private void handleExpenseClasses(RoutingContext ctx) {
logger.info("handleExpenseClasses got: {}?{}", ctx.request().path(), ctx.request().query());
String queryParam = StringUtils.trimToEmpty(ctx.request().getParam(QUERY));
String tenant = ctx.request().getHeader(OKAPI_HEADER_TENANT);
if (queryParam.contains(BAD_QUERY)) {
serverResponse(ctx, 400, APPLICATION_JSON, Response.Status.BAD_REQUEST.getReasonPhrase());
} else if (queryParam.contains(ID_FOR_INTERNAL_SERVER_ERROR) || GET_VOUCHERS_ERROR_TENANT.equals(tenant)) {
serverResponse(ctx, 500, APPLICATION_JSON, Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase());
} else {
Supplier<List<ExpenseClass>> getFromFile = () -> {
try {
return new JsonObject(getMockData(EXPENSE_CLASSES_LIST_PATH)).mapTo(ExpenseClassCollection.class).getExpenseClasses();
} catch (IOException e) {
return Collections.emptyList();
}
};
ExpenseClassCollection expenseClassCollection = new ExpenseClassCollection();
List<ExpenseClass> expenseClasses = getMockEntries(ResourcePathResolver.resourcesPath(EXPENSE_CLASSES_URL), ExpenseClass.class).orElseGet(getFromFile);
expenseClassCollection.withExpenseClasses(expenseClasses);
JsonObject expenseClassesJson = JsonObject.mapFrom(expenseClassCollection);
logger.info(expenseClassesJson.encodePrettily());
addServerRqRsData(HttpMethod.GET, BATCH_GROUPS, expenseClassesJson);
serverResponse(ctx, 200, APPLICATION_JSON, expenseClassesJson.encode());
}
}
Aggregations