Skip to content

Commit

Permalink
Merge branch 'master' into CIRC-2138
Browse files Browse the repository at this point in the history
  • Loading branch information
kapil-epam committed Sep 23, 2024
2 parents 2a7598c + 28aa0b7 commit d1a51ed
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
INSERT INTO ${myuniversity}_${mymodule}.staff_slips(id, jsonb)
VALUES ('0b52bca7-db17-4e91-a740-7872ed6d7323',
jsonb_build_object(
'id', '0b52bca7-db17-4e91-a740-7872ed6d7323',
'name', 'Due date receipt',
'active', true,
'template', '<p></p>'))
ON CONFLICT DO NOTHING;
5 changes: 5 additions & 0 deletions src/main/resources/templates/db_scripts/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@
"run": "after",
"snippetPath": "fixSpellingOfFulfillmentPreference.sql",
"fromModuleVersion": "17.1.2"
},
{
"run": "after",
"snippetPath": "add_due_date_slips.sql",
"fromModuleVersion": "17.3.0"
}
]
}
2 changes: 1 addition & 1 deletion src/test/java/org/folio/rest/api/StaffSlipsApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void canGetStaffSlipReferenceData()
JsonArray slipsJsonArray = getResponse.getJson().getJsonArray("staffSlips");
Object [] names = slipsJsonArray.stream().map(o -> ((JsonObject) o).getString(NAME_KEY)).toArray();
assertThat(names, arrayContainingInAnyOrder("Hold", "Transit", "Request delivery", "Pick slip",
"Search slip (Hold requests)"));
"Search slip (Hold requests)","Due date receipt"));
}

/* Begin Tests */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.folio.rest.api.migration;

import io.vertx.core.json.JsonArray;
import io.vertx.core.json.JsonObject;
import org.folio.rest.api.StorageTestSuite;
import org.folio.rest.support.JsonResponse;
import org.folio.rest.support.ResponseHandler;
import org.hamcrest.core.Is;
import org.junit.Before;
import org.junit.Test;

import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

import static org.hamcrest.MatcherAssert.assertThat;


public class DueDateSlipsMigrationScriptTest extends StaffSlipsMigrationTestBase {
public static final String DUE_DATE_RECEIPT_ID = "0b52bca7-db17-4e91-a740-7872ed6d7323";
private static final String MIGRATION_SCRIPT = loadScript("add_due_date_slips.sql");

@Before
public void beforeEach() throws MalformedURLException {
StorageTestSuite.deleteAll(staffSlipsStorageUrl(""));
}

@Test
public void canMigrateStaffSlips() throws Exception {
executeMultipleSqlStatements(MIGRATION_SCRIPT);
CompletableFuture<JsonResponse> getCompleted = new CompletableFuture<>();
client.get(staffSlipsStorageUrl(""), StorageTestSuite.TENANT_ID,
ResponseHandler.json(getCompleted));
JsonResponse getResponse = getCompleted.get(5, TimeUnit.SECONDS);

assertThat(getResponse.getStatusCode(), Is.is(HttpURLConnection.HTTP_OK));

JsonArray slipsJsonArray = getResponse.getJson().getJsonArray("staffSlips");
JsonObject staffSlips = getRecordById(slipsJsonArray, DUE_DATE_RECEIPT_ID);

assertStaffSlip(staffSlips, DUE_DATE_RECEIPT_ID, "Due date receipt");
}
}

0 comments on commit d1a51ed

Please sign in to comment.