Search in sources :

Example 1 with HridSettings

use of org.folio.rest.jaxrs.model.HridSettings in project mod-inventory-storage by folio-org.

the class HridSettingsStorageParameterizedTest method cannotUpdateHridSettingsWithBadData.

@Test
public void cannotUpdateHridSettingsWithBadData() throws InterruptedException, ExecutionException, TimeoutException {
    log.info("Starting cannotUpdateHridSettingsWithBadData()");
    final CompletableFuture<Response> putCompleted = new CompletableFuture<>();
    final HridSettings newHridSettings = new HridSettings().withInstances(new HridSetting().withPrefix(instancePrefix).withStartNumber(instanceStartNumber)).withHoldings(new HridSetting().withPrefix(holdingPrefix).withStartNumber(holdingStartNumber)).withItems(new HridSetting().withPrefix(itemPrefix).withStartNumber(itemStartNumber));
    client.put(InterfaceUrls.hridSettingsStorageUrl(""), newHridSettings, TENANT_ID, json(putCompleted));
    final Response putResponse = putCompleted.get(5, SECONDS);
    verifyValidationError(putResponse, keyPart + '.' + testField, expectedValue);
    log.info("Finished cannotUpdateHridSettingsWithBadData()");
}
Also used : Response(org.folio.rest.support.Response) CompletableFuture(java.util.concurrent.CompletableFuture) HridSettings(org.folio.rest.jaxrs.model.HridSettings) HridSetting(org.folio.rest.jaxrs.model.HridSetting) Test(org.junit.Test)

Example 2 with HridSettings

use of org.folio.rest.jaxrs.model.HridSettings in project mod-inventory-storage by folio-org.

the class HridSettingsStorageTest method canGetNextInstanceHridAfterSettingStartNumberWithoutLeadingZeroes.

@Test
public void canGetNextInstanceHridAfterSettingStartNumberWithoutLeadingZeroes(TestContext testContext) {
    log.info("Starting canGetNextInstanceHridAfterSettingStartNumberWithoutLeadingZeroes()");
    final HridSettings newHridSettings = new HridSettings().withInstances(new HridSetting().withPrefix("in").withStartNumber(250L)).withHoldings(new HridSetting().withPrefix("ho").withStartNumber(1L)).withItems(new HridSetting().withPrefix("it").withStartNumber(1L)).withCommonRetainLeadingZeroes(false);
    hridManager.updateHridSettings(newHridSettings).onComplete(testContext.asyncAssertSuccess(hridSettingsResult -> getNextInstanceHrid().compose(hrid -> validateHrid(hrid, "in250", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextInstanceHridAfterSettingStartNumberWithoutLeadingZeroes()")))));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) TestContext(io.vertx.ext.unit.TestContext) Item(org.folio.rest.jaxrs.model.Item) 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) Instance(org.folio.rest.jaxrs.model.Instance) RunWith(org.junit.runner.RunWith) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) Timeout(io.vertx.ext.unit.junit.Timeout) HoldingsRecord(org.folio.rest.jaxrs.model.HoldingsRecord) 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) Rule(org.junit.Rule) 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) HridSettings(org.folio.rest.jaxrs.model.HridSettings) HridSetting(org.folio.rest.jaxrs.model.HridSetting) Test(org.junit.Test)

Example 3 with HridSettings

use of org.folio.rest.jaxrs.model.HridSettings in project mod-inventory-storage by folio-org.

the class HridSettingsStorageTest method canGetNextInstanceHridAfterSettingStartNumber.

@Test
public void canGetNextInstanceHridAfterSettingStartNumber(TestContext testContext) {
    log.info("Starting canGetNextInstanceHridAfterSettingStartNumber()");
    final HridSettings newHridSettings = new HridSettings().withInstances(new HridSetting().withPrefix("in").withStartNumber(250L)).withHoldings(new HridSetting().withPrefix("ho").withStartNumber(1L)).withItems(new HridSetting().withPrefix("it").withStartNumber(1L));
    hridManager.updateHridSettings(newHridSettings).onComplete(testContext.asyncAssertSuccess(hridSettingsResult -> getNextInstanceHrid().compose(hrid -> validateHrid(hrid, "in00000000250", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextInstanceHridAfterSettingStartNumber()")))));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) TestContext(io.vertx.ext.unit.TestContext) Item(org.folio.rest.jaxrs.model.Item) 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) Instance(org.folio.rest.jaxrs.model.Instance) RunWith(org.junit.runner.RunWith) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) Timeout(io.vertx.ext.unit.junit.Timeout) HoldingsRecord(org.folio.rest.jaxrs.model.HoldingsRecord) 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) Rule(org.junit.Rule) 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) HridSettings(org.folio.rest.jaxrs.model.HridSettings) HridSetting(org.folio.rest.jaxrs.model.HridSetting) Test(org.junit.Test)

Example 4 with HridSettings

use of org.folio.rest.jaxrs.model.HridSettings in project mod-inventory-storage by folio-org.

the class HridSettingsStorageTest method canGetNextHridWhenStartNumberIsLongWithoutLeadingZeroes.

@Test
public void canGetNextHridWhenStartNumberIsLongWithoutLeadingZeroes(TestContext testContext) {
    log.info("Starting canGetNextHridWhenStartNumberIsLongWithoutLeadingZeroes()");
    final HridSettings newHridSettings = new HridSettings().withInstances(new HridSetting().withStartNumber(9_999_999_997L)).withHoldings(new HridSetting().withStartNumber(9_999_999_998L)).withItems(new HridSetting().withStartNumber(9_999_999_999L)).withCommonRetainLeadingZeroes(false);
    hridManager.updateHridSettings(newHridSettings).compose(v -> getNextInstanceHrid()).compose(hrid -> validateHrid(hrid, "9999999997", testContext)).compose(v -> getNextHoldingsHrid()).compose(hrid -> validateHrid(hrid, "9999999998", testContext)).compose(v -> getNextItemHrid()).compose(hrid -> validateHrid(hrid, "9999999999", testContext)).onComplete(testContext.asyncAssertSuccess(v1 -> log.info("Finished canGetNextHridWhenStartNumberIsLongWithoutLeadingZeroes()")));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) TestContext(io.vertx.ext.unit.TestContext) Item(org.folio.rest.jaxrs.model.Item) 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) Instance(org.folio.rest.jaxrs.model.Instance) RunWith(org.junit.runner.RunWith) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) Timeout(io.vertx.ext.unit.junit.Timeout) HoldingsRecord(org.folio.rest.jaxrs.model.HoldingsRecord) 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) Rule(org.junit.Rule) 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) HridSettings(org.folio.rest.jaxrs.model.HridSettings) HridSetting(org.folio.rest.jaxrs.model.HridSetting) Test(org.junit.Test)

Example 5 with HridSettings

use of org.folio.rest.jaxrs.model.HridSettings in project mod-inventory-storage by folio-org.

the class HridSettingsStorageTest method canGetNextHoldingHridAfterSettingStartNumberWithoutLeadingZeroes.

@Test
public void canGetNextHoldingHridAfterSettingStartNumberWithoutLeadingZeroes(TestContext testContext) {
    log.info("Starting canGetNextHoldingHridAfterSettingStartNumberWithoutLeadingZeroes()");
    final HridSettings newHridSettings = new HridSettings().withInstances(new HridSetting().withPrefix("in").withStartNumber(1L)).withHoldings(new HridSetting().withPrefix("ho").withStartNumber(7890L)).withItems(new HridSetting().withPrefix("it").withStartNumber(1L)).withCommonRetainLeadingZeroes(false);
    hridManager.updateHridSettings(newHridSettings).onComplete(testContext.asyncAssertSuccess(hridSettings -> getNextHoldingsHrid().compose(hrid -> validateHrid(hrid, "ho7890", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextHoldingHridAfterSettingStartNumberWithoutLeadingZeroes()")))));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) TestContext(io.vertx.ext.unit.TestContext) Item(org.folio.rest.jaxrs.model.Item) 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) Instance(org.folio.rest.jaxrs.model.Instance) RunWith(org.junit.runner.RunWith) TimeoutException(java.util.concurrent.TimeoutException) CompletableFuture(java.util.concurrent.CompletableFuture) Timeout(io.vertx.ext.unit.junit.Timeout) HoldingsRecord(org.folio.rest.jaxrs.model.HoldingsRecord) 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) Rule(org.junit.Rule) 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) HridSettings(org.folio.rest.jaxrs.model.HridSettings) HridSetting(org.folio.rest.jaxrs.model.HridSetting) Test(org.junit.Test)

Aggregations

HridSettings (org.folio.rest.jaxrs.model.HridSettings)17 CompletableFuture (java.util.concurrent.CompletableFuture)14 Response (org.folio.rest.support.Response)14 Test (org.junit.Test)14 HridSetting (org.folio.rest.jaxrs.model.HridSetting)13 Future (io.vertx.core.Future)11 LogManager (org.apache.logging.log4j.LogManager)11 Logger (org.apache.logging.log4j.Logger)11 PostgresClient (org.folio.rest.persist.PostgresClient)11 HridManager (org.folio.rest.support.HridManager)11 Promise (io.vertx.core.Promise)9 Vertx (io.vertx.core.Vertx)9 Async (io.vertx.ext.unit.Async)9 TestContext (io.vertx.ext.unit.TestContext)9 Timeout (io.vertx.ext.unit.junit.Timeout)9 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)9 Row (io.vertx.sqlclient.Row)9 UUID (java.util.UUID)9 ExecutionException (java.util.concurrent.ExecutionException)9 SECONDS (java.util.concurrent.TimeUnit.SECONDS)9