Search in sources :

Example 11 with HridSettings

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

the class HridSettingsStorageTest method cannotUpdateHridSettingsWithBadTenant.

@Test
public void cannotUpdateHridSettingsWithBadTenant() throws InterruptedException, ExecutionException, TimeoutException {
    log.info("Starting cannotUpdateHridSettingsWithBadTenant()");
    final CompletableFuture<Response> putCompleted = new CompletableFuture<>();
    final HridSettings newHridSettings = new HridSettings().withInstances(new HridSetting().withPrefix("inst").withStartNumber(100L)).withHoldings(new HridSetting().withPrefix("hold").withStartNumber(200L)).withItems(new HridSetting().withPrefix("item").withStartNumber(500L));
    client.put(InterfaceUrls.hridSettingsStorageUrl(""), newHridSettings, "BAD", text(putCompleted));
    final Response putResponse = putCompleted.get(5, SECONDS);
    assertThat(putResponse.getStatusCode(), is(500));
    log.info("Finished canUpdateHridSettings()");
}
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 12 with HridSettings

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

the class HridSettingsStorageTest method canGetNextHoldingHridAfterSettingStartNumber.

@Test
public void canGetNextHoldingHridAfterSettingStartNumber(TestContext testContext) {
    log.info("Starting canGetNextHoldingHridAfterSettingStartNumber()");
    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));
    hridManager.updateHridSettings(newHridSettings).onComplete(testContext.asyncAssertSuccess(hridSettings -> getNextHoldingsHrid().compose(hrid -> validateHrid(hrid, "ho00000007890", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextHoldingHridAfterSettingStartNumber()")))));
}
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 13 with HridSettings

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

the class HridSettingsStorageTest method cannotUpdateHridSettingsID.

@Test
public void cannotUpdateHridSettingsID() throws InterruptedException, ExecutionException, TimeoutException {
    log.info("Starting cannotUpdateHridSettingsID()");
    final CompletableFuture<Response> originalGetCompleted = new CompletableFuture<>();
    client.get(InterfaceUrls.hridSettingsStorageUrl(""), TENANT_ID, json(originalGetCompleted));
    final Response originalGetResponse = originalGetCompleted.get(5, SECONDS);
    assertThat(originalGetResponse.getStatusCode(), is(200));
    final HridSettings originalHridSettings = originalGetResponse.getJson().mapTo(HridSettings.class);
    final String uuid = UUID.randomUUID().toString();
    final HridSettings newHridSettings = new HridSettings().withId(uuid).withInstances(new HridSetting().withPrefix("inst").withStartNumber(100L)).withHoldings(new HridSetting().withPrefix("hold").withStartNumber(200L)).withItems(new HridSetting().withPrefix("item").withStartNumber(500L));
    final CompletableFuture<Response> putCompleted = new CompletableFuture<>();
    client.put(InterfaceUrls.hridSettingsStorageUrl(""), newHridSettings, TENANT_ID, empty(putCompleted));
    final Response putResponse = putCompleted.get(5, SECONDS);
    assertThat(putResponse.getStatusCode(), is(204));
    final CompletableFuture<Response> getAfterUpdateCompleted = new CompletableFuture<>();
    client.get(InterfaceUrls.hridSettingsStorageUrl(""), TENANT_ID, json(getAfterUpdateCompleted));
    final Response getAfterUpdateResponse = getAfterUpdateCompleted.get(5, SECONDS);
    final HridSettings actualHridSettings = getAfterUpdateResponse.getJson().mapTo(HridSettings.class);
    assertThat(actualHridSettings.getId(), not(uuid));
    assertThat(actualHridSettings.getId(), is(originalHridSettings.getId()));
    assertThat(actualHridSettings.getInstances(), is(notNullValue()));
    assertThat(actualHridSettings.getInstances().getPrefix(), is(newHridSettings.getInstances().getPrefix()));
    assertThat(actualHridSettings.getInstances().getStartNumber(), is(newHridSettings.getInstances().getStartNumber()));
    assertThat(actualHridSettings.getHoldings(), is(notNullValue()));
    assertThat(actualHridSettings.getHoldings().getPrefix(), is(newHridSettings.getHoldings().getPrefix()));
    assertThat(actualHridSettings.getHoldings().getStartNumber(), is(newHridSettings.getHoldings().getStartNumber()));
    assertThat(actualHridSettings.getItems(), is(notNullValue()));
    assertThat(actualHridSettings.getItems().getPrefix(), is(newHridSettings.getItems().getPrefix()));
    assertThat(actualHridSettings.getItems().getStartNumber(), is(newHridSettings.getItems().getStartNumber()));
    log.info("Finished cannotUpdateHridSettingsID()");
}
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 14 with HridSettings

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

the class HridSettingsStorageTest method canGetNextItemHridAfterSettingStartNumber.

@Test
public void canGetNextItemHridAfterSettingStartNumber(TestContext testContext) {
    log.info("Starting canGetNextItemHridAfterSettingStartNumber()");
    final HridSettings newHridSettings = new HridSettings().withInstances(new HridSetting().withPrefix("in").withStartNumber(1L)).withHoldings(new HridSetting().withPrefix("ho").withStartNumber(1L)).withItems(new HridSetting().withPrefix("it").withStartNumber(87654321L));
    hridManager.updateHridSettings(newHridSettings).onComplete(testContext.asyncAssertSuccess(hridSettings -> getNextItemHrid().compose(hrid -> validateHrid(hrid, "it00087654321", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextItemHridAfterSettingStartNumber()")))));
}
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 15 with HridSettings

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

the class HridSettingsStorageTest method canUpdateHridSettings.

@Test
public void canUpdateHridSettings() throws InterruptedException, ExecutionException, TimeoutException {
    log.info("Starting canUpdateHridSettings()");
    final CompletableFuture<Response> putCompleted = new CompletableFuture<>();
    final HridSettings newHridSettings = new HridSettings().withInstances(new HridSetting().withPrefix("inst").withStartNumber(100L)).withHoldings(new HridSetting().withPrefix("hold").withStartNumber(200L)).withItems(new HridSetting().withPrefix("item").withStartNumber(500L));
    client.put(InterfaceUrls.hridSettingsStorageUrl(""), newHridSettings, TENANT_ID, empty(putCompleted));
    final Response putResponse = putCompleted.get(5, SECONDS);
    assertThat(putResponse.getStatusCode(), is(204));
    final CompletableFuture<Response> getCompleted = new CompletableFuture<>();
    client.get(InterfaceUrls.hridSettingsStorageUrl(""), TENANT_ID, json(getCompleted));
    final Response getResponse = getCompleted.get(5, SECONDS);
    final HridSettings actualHridSettings = getResponse.getJson().mapTo(HridSettings.class);
    assertThat(actualHridSettings.getInstances(), is(notNullValue()));
    assertThat(actualHridSettings.getInstances().getPrefix(), is(newHridSettings.getInstances().getPrefix()));
    assertThat(actualHridSettings.getInstances().getStartNumber(), is(newHridSettings.getInstances().getStartNumber()));
    assertThat(actualHridSettings.getHoldings(), is(notNullValue()));
    assertThat(actualHridSettings.getHoldings().getPrefix(), is(newHridSettings.getHoldings().getPrefix()));
    assertThat(actualHridSettings.getHoldings().getStartNumber(), is(newHridSettings.getHoldings().getStartNumber()));
    assertThat(actualHridSettings.getItems(), is(notNullValue()));
    assertThat(actualHridSettings.getItems().getPrefix(), is(newHridSettings.getItems().getPrefix()));
    assertThat(actualHridSettings.getItems().getStartNumber(), is(newHridSettings.getItems().getStartNumber()));
    log.info("Finished canUpdateHridSettings()");
}
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)

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