use of org.folio.rest.jaxrs.model.ExportConfig in project mod-invoice by folio-org.
the class MockServer method handleGetBatchVoucherExportConfigById.
private void handleGetBatchVoucherExportConfigById(RoutingContext ctx) {
logger.info("handleGetBatchVoucherExportConfigById got: GET " + ctx.request().path());
String id = ctx.request().getParam(AbstractHelper.ID);
logger.info("id: " + id);
if (ID_FOR_INTERNAL_SERVER_ERROR.equals(id)) {
serverResponse(ctx, 500, APPLICATION_JSON, Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase());
} else {
JsonObject exportConfig = getMockEntry(BATCH_VOUCHER_EXPORT_CONFIGS, id).orElseGet(getJsonObjectFromFile(BATCH_VOUCHER_EXPORT_CONFIG_SAMPLE_PATH, id));
if (exportConfig == null) {
ctx.response().setStatusCode(404).end(id);
} else {
ExportConfig exportConfigSchema = exportConfig.mapTo(ExportConfig.class);
exportConfigSchema.setId(id);
exportConfigSchema.setUploadURI(ftpUri);
// validate content against schema
exportConfig = JsonObject.mapFrom(exportConfigSchema);
addServerRqRsData(HttpMethod.GET, BATCH_VOUCHER_EXPORT_CONFIGS, exportConfig);
serverResponse(ctx, 200, APPLICATION_JSON, exportConfig.encodePrettily());
}
}
}
use of org.folio.rest.jaxrs.model.ExportConfig in project mod-invoice by folio-org.
the class BatchVoucherExportConfigTest method testPostExportConfig.
@Test
public void testPostExportConfig() throws IOException {
logger.info("=== Test create batch voucher export config ===");
String body = getMockData(BATCH_VOUCHER_EXPORT_CONFIG_SAMPLE_PATH_WITH_ID);
final ExportConfig exportConfig = verifyPostResponse(BATCH_VOUCHER_EXPORT_CONFIGS_ENDPOINT, body, prepareHeaders(X_OKAPI_TENANT), APPLICATION_JSON, 201).as(ExportConfig.class);
String id = exportConfig.getId();
assertThat(id, notNullValue());
assertThat(MockServer.serverRqRs.get(BATCH_VOUCHER_EXPORT_CONFIGS, HttpMethod.POST), hasSize(1));
}
use of org.folio.rest.jaxrs.model.ExportConfig in project mod-invoice by folio-org.
the class BatchVoucherExportConfigTest method testPutExportConfig.
@Test
public void testPutExportConfig() {
logger.info("=== Test edit batch voucher export configuration - 204 expected ===");
ExportConfig exportConfig = getMockAsJson(BATCH_VOUCHER_EXPORT_CONFIG_SAMPLE_PATH_WITH_ID).mapTo(ExportConfig.class);
exportConfig.setFormat(Format.APPLICATION_JSON);
verifyPut(BATCH_VOUCHER_EXPORT_CONFIG_ENDPOINT_WITH_ID, JsonObject.mapFrom(exportConfig), "", 204);
assertThat(MockServer.serverRqRs.get(BATCH_VOUCHER_EXPORT_CONFIGS, HttpMethod.PUT), hasSize(1));
}
use of org.folio.rest.jaxrs.model.ExportConfig in project mod-invoice by folio-org.
the class MockServer method handleGetBatchVoucherExportConfigs.
private void handleGetBatchVoucherExportConfigs(RoutingContext ctx) {
logger.info("handleGetBatchVoucherExportConfigs got: {}?{}", ctx.request().path(), ctx.request().query());
verifyIntegerParams(ctx, new String[] { LIMIT, OFFSET });
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) || ERROR_TENANT.equals(tenant)) {
serverResponse(ctx, 500, APPLICATION_JSON, Response.Status.INTERNAL_SERVER_ERROR.getReasonPhrase());
} else {
Supplier<List<ExportConfig>> getFromFile = () -> {
try {
return new JsonObject(getMockData(BATCH_VOUCHER_EXPORT_CONFIGS_SAMPLE_PATH)).mapTo(ExportConfigCollection.class).getExportConfigs();
} catch (IOException e) {
return Collections.emptyList();
}
};
ExportConfigCollection exportConfigCollection = new ExportConfigCollection();
List<ExportConfig> exportConfigs = getMockEntries(BATCH_VOUCHER_EXPORT_CONFIGS, ExportConfig.class).orElseGet(getFromFile);
exportConfigCollection.setExportConfigs(exportConfigs);
exportConfigCollection.setTotalRecords(exportConfigCollection.getExportConfigs().size());
JsonObject exportConfigsJson = JsonObject.mapFrom(exportConfigCollection);
logger.info(exportConfigsJson.encodePrettily());
addServerRqRsData(HttpMethod.GET, BATCH_VOUCHER_EXPORT_CONFIGS, exportConfigsJson);
serverResponse(ctx, 200, APPLICATION_JSON, exportConfigsJson.encode());
}
}
use of org.folio.rest.jaxrs.model.ExportConfig in project mod-invoice by folio-org.
the class BatchVoucherExportConfigTest method testGetExportConfig.
@Test
public void testGetExportConfig() {
logger.info("=== Test get batch voucher export configuration by id ===");
final ExportConfig exportConfig = verifySuccessGet(BATCH_VOUCHER_EXPORT_CONFIG_ENDPOINT_WITH_ID, ExportConfig.class);
assertThat(MockServer.serverRqRs.get(BATCH_VOUCHER_EXPORT_CONFIGS, HttpMethod.GET), hasSize(1));
Assertions.assertEquals(EXPORT_CONFIG_ID, exportConfig.getId());
}
Aggregations