Search in sources :

Example 6 with HridManager

use of org.folio.rest.support.HridManager in project mod-inventory-storage by folio-org.

the class HridSettingsStorageTest method canGetNextHoldingHrid.

@Test
public void canGetNextHoldingHrid(TestContext testContext) {
    log.info("Starting canGetNextHoldingHrid()");
    final Vertx vertx = StorageTestSuite.getVertx();
    final PostgresClient postgresClient = PostgresClient.getInstance(vertx, TENANT_ID);
    final HridManager hridManager = new HridManager(vertx.getOrCreateContext(), postgresClient);
    hridManager.getNextHoldingsHrid().compose(hrid -> validateHrid(hrid, "ho00000000001", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextHoldingHrid()")));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) Response(org.folio.rest.support.Response) TENANT_ID(org.folio.rest.api.StorageTestSuite.TENANT_ID) CoreMatchers.not(org.hamcrest.CoreMatchers.not) RunWith(org.junit.runner.RunWith) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) HridSettings(org.folio.rest.jaxrs.model.HridSettings) InterfaceUrls(org.folio.rest.support.http.InterfaceUrls) Before(org.junit.Before) HridSetting(org.folio.rest.jaxrs.model.HridSetting) Promise(io.vertx.core.Promise) Vertx(io.vertx.core.Vertx) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) ResponseHandler.text(org.folio.rest.support.ResponseHandler.text) Future(io.vertx.core.Future) PostgresClient(org.folio.rest.persist.PostgresClient) HridManager(org.folio.rest.support.HridManager) ExecutionException(java.util.concurrent.ExecutionException) ResponseHandler.empty(org.folio.rest.support.ResponseHandler.empty) Logger(org.apache.logging.log4j.Logger) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) Row(io.vertx.sqlclient.Row) ResponseHandler.json(org.folio.rest.support.ResponseHandler.json) LogManager(org.apache.logging.log4j.LogManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) HridManager(org.folio.rest.support.HridManager) PostgresClient(org.folio.rest.persist.PostgresClient) Vertx(io.vertx.core.Vertx) Test(org.junit.Test)

Example 7 with HridManager

use of org.folio.rest.support.HridManager in project mod-inventory-storage by folio-org.

the class HridSettingsStorageTest method canGetNextItemHrid.

@Test
public void canGetNextItemHrid(TestContext testContext) {
    log.info("Starting canGetNextItemHrid()");
    final Vertx vertx = StorageTestSuite.getVertx();
    final PostgresClient postgresClient = PostgresClient.getInstance(vertx, TENANT_ID);
    final HridManager hridManager = new HridManager(vertx.getOrCreateContext(), postgresClient);
    hridManager.getNextItemHrid().compose(hrid -> validateHrid(hrid, "it00000000001", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextItemHrid()")));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) Response(org.folio.rest.support.Response) TENANT_ID(org.folio.rest.api.StorageTestSuite.TENANT_ID) CoreMatchers.not(org.hamcrest.CoreMatchers.not) RunWith(org.junit.runner.RunWith) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) HridSettings(org.folio.rest.jaxrs.model.HridSettings) InterfaceUrls(org.folio.rest.support.http.InterfaceUrls) Before(org.junit.Before) HridSetting(org.folio.rest.jaxrs.model.HridSetting) Promise(io.vertx.core.Promise) Vertx(io.vertx.core.Vertx) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) ResponseHandler.text(org.folio.rest.support.ResponseHandler.text) Future(io.vertx.core.Future) PostgresClient(org.folio.rest.persist.PostgresClient) HridManager(org.folio.rest.support.HridManager) ExecutionException(java.util.concurrent.ExecutionException) ResponseHandler.empty(org.folio.rest.support.ResponseHandler.empty) Logger(org.apache.logging.log4j.Logger) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) Row(io.vertx.sqlclient.Row) ResponseHandler.json(org.folio.rest.support.ResponseHandler.json) LogManager(org.apache.logging.log4j.LogManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) HridManager(org.folio.rest.support.HridManager) PostgresClient(org.folio.rest.persist.PostgresClient) Vertx(io.vertx.core.Vertx) Test(org.junit.Test)

Example 8 with HridManager

use of org.folio.rest.support.HridManager in project mod-inventory-storage by folio-org.

the class HridSettingsStorageTest method canGetNextInstanceHrid.

@Test
public void canGetNextInstanceHrid(TestContext testContext) {
    log.info("Starting canGetNextInstanceHrid()");
    final Vertx vertx = StorageTestSuite.getVertx();
    final PostgresClient postgresClient = PostgresClient.getInstance(vertx, TENANT_ID);
    final HridManager hridManager = new HridManager(vertx.getOrCreateContext(), postgresClient);
    hridManager.getNextInstanceHrid().compose(hrid -> validateHrid(hrid, "in00000000001", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextInstanceHrid()")));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) TestContext(io.vertx.ext.unit.TestContext) Async(io.vertx.ext.unit.Async) Response(org.folio.rest.support.Response) TENANT_ID(org.folio.rest.api.StorageTestSuite.TENANT_ID) CoreMatchers.not(org.hamcrest.CoreMatchers.not) RunWith(org.junit.runner.RunWith) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) HridSettings(org.folio.rest.jaxrs.model.HridSettings) InterfaceUrls(org.folio.rest.support.http.InterfaceUrls) Before(org.junit.Before) HridSetting(org.folio.rest.jaxrs.model.HridSetting) Promise(io.vertx.core.Promise) Vertx(io.vertx.core.Vertx) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) UUID(java.util.UUID) VertxUnitRunner(io.vertx.ext.unit.junit.VertxUnitRunner) ResponseHandler.text(org.folio.rest.support.ResponseHandler.text) Future(io.vertx.core.Future) PostgresClient(org.folio.rest.persist.PostgresClient) HridManager(org.folio.rest.support.HridManager) ExecutionException(java.util.concurrent.ExecutionException) ResponseHandler.empty(org.folio.rest.support.ResponseHandler.empty) Logger(org.apache.logging.log4j.Logger) IsNull.notNullValue(org.hamcrest.core.IsNull.notNullValue) Row(io.vertx.sqlclient.Row) ResponseHandler.json(org.folio.rest.support.ResponseHandler.json) LogManager(org.apache.logging.log4j.LogManager) SECONDS(java.util.concurrent.TimeUnit.SECONDS) HridManager(org.folio.rest.support.HridManager) PostgresClient(org.folio.rest.persist.PostgresClient) Vertx(io.vertx.core.Vertx) Test(org.junit.Test)

Example 9 with HridManager

use of org.folio.rest.support.HridManager in project mod-inventory-storage by folio-org.

the class HridSettingsStorageAPI method putHridSettingsStorageHridSettings.

@Validate
@Override
public void putHridSettingsStorageHridSettings(HridSettings hridSettings, Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
    try {
        vertxContext.runOnContext(v -> {
            try {
                final PostgresClient postgresClient = PostgresClient.getInstance(vertxContext.owner(), TenantTool.tenantId(okapiHeaders));
                final HridManager hridManager = new HridManager(vertxContext, postgresClient);
                hridManager.updateHridSettings(hridSettings).map(success -> successPut(asyncResultHandler)).otherwise(error -> internalErrorPut(asyncResultHandler, error));
            } catch (Exception e) {
                internalErrorPut(asyncResultHandler, e);
            }
        });
    } catch (Exception e) {
        internalErrorPut(asyncResultHandler, e);
    }
}
Also used : Validate(org.folio.rest.annotations.Validate) TenantTool(org.folio.rest.tools.utils.TenantTool) Context(io.vertx.core.Context) Future(io.vertx.core.Future) PostgresClient(org.folio.rest.persist.PostgresClient) HridManager(org.folio.rest.support.HridManager) Logger(org.apache.logging.log4j.Logger) Response(javax.ws.rs.core.Response) Map(java.util.Map) AsyncResult(io.vertx.core.AsyncResult) Handler(io.vertx.core.Handler) LogManager(org.apache.logging.log4j.LogManager) HridSettings(org.folio.rest.jaxrs.model.HridSettings) HridSettingsStorage(org.folio.rest.jaxrs.resource.HridSettingsStorage) HridManager(org.folio.rest.support.HridManager) PostgresClient(org.folio.rest.persist.PostgresClient) Validate(org.folio.rest.annotations.Validate)

Example 10 with HridManager

use of org.folio.rest.support.HridManager in project mod-inventory-storage by folio-org.

the class HridSettingsStorageAPI method getHridSettingsStorageHridSettings.

@Validate
@Override
public void getHridSettingsStorageHridSettings(Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) {
    try {
        vertxContext.runOnContext(v -> {
            try {
                final PostgresClient postgresClient = PostgresClient.getInstance(vertxContext.owner(), TenantTool.tenantId(okapiHeaders));
                final HridManager hridManager = new HridManager(vertxContext, postgresClient);
                hridManager.getHridSettings().map(hridSettings -> successGet(asyncResultHandler, hridSettings)).otherwise(error -> internalErrorGet(asyncResultHandler, error));
            } catch (Exception e) {
                internalErrorGet(asyncResultHandler, e);
            }
        });
    } catch (Exception e) {
        internalErrorGet(asyncResultHandler, e);
    }
}
Also used : Validate(org.folio.rest.annotations.Validate) TenantTool(org.folio.rest.tools.utils.TenantTool) Context(io.vertx.core.Context) Future(io.vertx.core.Future) PostgresClient(org.folio.rest.persist.PostgresClient) HridManager(org.folio.rest.support.HridManager) Logger(org.apache.logging.log4j.Logger) Response(javax.ws.rs.core.Response) Map(java.util.Map) AsyncResult(io.vertx.core.AsyncResult) Handler(io.vertx.core.Handler) LogManager(org.apache.logging.log4j.LogManager) HridSettings(org.folio.rest.jaxrs.model.HridSettings) HridSettingsStorage(org.folio.rest.jaxrs.resource.HridSettingsStorage) HridManager(org.folio.rest.support.HridManager) PostgresClient(org.folio.rest.persist.PostgresClient) Validate(org.folio.rest.annotations.Validate)

Aggregations

HridManager (org.folio.rest.support.HridManager)10 Future (io.vertx.core.Future)9 LogManager (org.apache.logging.log4j.LogManager)9 Logger (org.apache.logging.log4j.Logger)9 PostgresClient (org.folio.rest.persist.PostgresClient)9 HridSettings (org.folio.rest.jaxrs.model.HridSettings)8 Vertx (io.vertx.core.Vertx)7 Async (io.vertx.ext.unit.Async)7 Row (io.vertx.sqlclient.Row)7 Before (org.junit.Before)7 Promise (io.vertx.core.Promise)6 TestContext (io.vertx.ext.unit.TestContext)6 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)6 UUID (java.util.UUID)6 CompletableFuture (java.util.concurrent.CompletableFuture)6 ExecutionException (java.util.concurrent.ExecutionException)6 SECONDS (java.util.concurrent.TimeUnit.SECONDS)6 TimeoutException (java.util.concurrent.TimeoutException)6 TENANT_ID (org.folio.rest.api.StorageTestSuite.TENANT_ID)6 HridSetting (org.folio.rest.jaxrs.model.HridSetting)6