use of org.folio.rest.api.StorageTestSuite.TENANT_ID in project mod-inventory-storage by folio-org.
the class HridSettingsStorageTest method canGetNextInstanceHridWithoutLeadingZeroes.
@Test
public void canGetNextInstanceHridWithoutLeadingZeroes(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.updateHridSettings(initialHridSettingsWithoutLeadingZeroes).onComplete(testContext.asyncAssertSuccess(hridSettingsResult -> hridManager.getNextInstanceHrid().compose(hrid -> validateHrid(hrid, "in1", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextInstanceHridWithoutLeadingZeroes()")))));
}
use of org.folio.rest.api.StorageTestSuite.TENANT_ID in project mod-inventory-storage by folio-org.
the class HridSettingsStorageTest method canGetNextItemHridMultipleTimes.
@Test
public void canGetNextItemHridMultipleTimes(TestContext testContext) {
log.info("Starting canGetNextItemHridMultipleTimes()");
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)).compose(v -> hridManager.getNextItemHrid()).compose(hrid -> validateHrid(hrid, "it00000000002", testContext)).compose(v -> hridManager.getNextItemHrid()).compose(hrid -> validateHrid(hrid, "it00000000003", testContext)).compose(v -> hridManager.getNextItemHrid()).compose(hrid -> validateHrid(hrid, "it00000000004", testContext)).compose(v -> hridManager.getNextItemHrid()).compose(hrid -> validateHrid(hrid, "it00000000005", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextItemHridMultipleTimes()")));
}
use of org.folio.rest.api.StorageTestSuite.TENANT_ID in project mod-inventory-storage by folio-org.
the class HridSettingsStorageTest method canGetNextHoldingHridWithoutLeadingZeroes.
@Test
public void canGetNextHoldingHridWithoutLeadingZeroes(TestContext testContext) {
log.info("Starting canGetNextHoldingHridWithoutLeadingZeroes()");
final Vertx vertx = StorageTestSuite.getVertx();
final PostgresClient postgresClient = PostgresClient.getInstance(vertx, TENANT_ID);
final HridManager hridManager = new HridManager(vertx.getOrCreateContext(), postgresClient);
hridManager.updateHridSettings(initialHridSettingsWithoutLeadingZeroes).onComplete(testContext.asyncAssertSuccess(hridSettingsResult -> hridManager.getNextHoldingsHrid().compose(hrid -> validateHrid(hrid, "ho1", testContext)).onComplete(testContext.asyncAssertSuccess(v -> log.info("Finished canGetNextHoldingHridWithoutLeadingZeroes()")))));
}
use of org.folio.rest.api.StorageTestSuite.TENANT_ID in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method insert.
/**
* Insert n records into instance table where the title field is build using
* prefix and the number from 1 .. n.
*/
private void insert(TestContext testContext, PostgresClient pg, String prefix, int n) {
Async async = testContext.async();
String table = PostgresClient.convertToPsqlStandard(TENANT_ID) + ".instance";
String sql = "INSERT INTO " + table + " SELECT uuid, json_build_object('title', prefix || n, 'id', uuid)" + " FROM (SELECT n, prefix, md5(prefix || n)::uuid AS uuid" + " FROM (SELECT generate_series(1, " + n + ") AS n, '" + prefix + " ' AS prefix) AS tmp1" + " ) AS tmp2";
pg.execute(sql, testContext.asyncAssertSuccess(updated -> {
testContext.assertEquals(n, updated.rowCount());
async.complete();
}));
async.await(10000);
}
use of org.folio.rest.api.StorageTestSuite.TENANT_ID in project mod-inventory-storage by folio-org.
the class InstanceStorageTest method canPostSynchronousBatch.
@Test
public void canPostSynchronousBatch() throws Exception {
JsonArray instancesArray = new JsonArray();
int numberOfInstances = 1000;
instancesArray.add(uprooted(UUID.randomUUID()));
for (int i = 2; i < numberOfInstances; i++) {
instancesArray.add(smallAngryPlanet(UUID.randomUUID()));
}
instancesArray.add(temeraire(UUID.randomUUID()));
JsonObject instanceCollection = new JsonObject().put(INSTANCES_KEY, instancesArray);
CompletableFuture<Response> createCompleted = new CompletableFuture<>();
client.post(instancesStorageSyncUrl(""), instanceCollection, TENANT_ID, ResponseHandler.empty(createCompleted));
assertThat(createCompleted.get(30, SECONDS), statusCodeIs(HttpStatus.HTTP_CREATED));
JsonObject uprooted = instancesArray.getJsonObject(0);
JsonObject smallAngryPlanet = instancesArray.getJsonObject(numberOfInstances / 2);
JsonObject temeraire = instancesArray.getJsonObject(numberOfInstances - 1);
assertExists(uprooted);
assertExists(smallAngryPlanet);
assertExists(temeraire);
assertNotSuppressedFromDiscovery(instancesArray);
final List<JsonObject> createdInstances = instancesArray.stream().map(obj -> (JsonObject) obj).map(json -> json.getString("id")).map(this::getById).map(Response::getJson).collect(Collectors.toList());
assertCreateEventForInstances(createdInstances);
}
Aggregations