Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/folio-org/mod-orders into…
Browse files Browse the repository at this point in the history
… MODORDERS-967
  • Loading branch information
SerhiiNosko committed Nov 28, 2023
2 parents ce1c359 + 039940b commit d121b59
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 72 deletions.
104 changes: 60 additions & 44 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@
<!--Test dependencies-->
<junit-jupiter.version>5.10.0</junit-jupiter.version>
<testcontainers-bom.version>1.19.1</testcontainers-bom.version>
<junit-bom.version>5.9.0</junit-bom.version>
<junit-bom.version>5.10.0</junit-bom.version>
<jmockit.version>1.49</jmockit.version>

<!--Sonar exclusion-->
<sonar.exclusions>**/models/**.java,**/unopen/**.java</sonar.exclusions>
Expand Down Expand Up @@ -121,6 +122,46 @@
</snapshotRepository>
</distributionManagement>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.13.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>${testcontainers-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>${log4j.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>${vertx.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.folio</groupId>
Expand Down Expand Up @@ -243,9 +284,16 @@
<artifactId>junit-platform-runner</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -257,7 +305,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>4.6.1</version>
<version>4.8.0</version>
<scope>test</scope>
</dependency>
<!-- The RMB runtime defines usage of log4j2 for vert.x logging interface. Including Log4j 2 SLF4J Binding to allow SLF4J API to use Log4j 2 as the implementation. -->
Expand Down Expand Up @@ -795,11 +843,18 @@
<exclude>org/folio/rest/impl/**Test.class</exclude>
</excludes>
<includes>
<include>org/folio/ApiTestSuite.class</include>
<include>org/folio/DataImportTestSuite.class</include>
<include>org/folio/ApiTestSuite.java</include>
<include>org/folio/DataImportTestSuite.java</include>
</includes>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
<!--org.apache.maven.surefire.junitplatform.JUnitPlatformProvider configured to run Junit5 and Junit4 tests-->
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit-platform</artifactId>
<version>${maven-surefire-plugin.version}</version>
</dependency>
</dependencies>
</plugin>

<plugin>
Expand All @@ -818,43 +873,4 @@

</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-bom</artifactId>
<version>2.13.4</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-bom</artifactId>
<version>${testcontainers-bom.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>${log4j.version}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-stack-depchain</artifactId>
<version>${vertx.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
10 changes: 3 additions & 7 deletions src/test/java/org/folio/rest/impl/PieceApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import io.restassured.http.Header;
import io.vertx.core.json.JsonObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.folio.ApiTestSuite;
Expand All @@ -58,9 +60,6 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import io.restassured.http.Header;
import io.vertx.core.json.JsonObject;

public class PieceApiTest {

private static final Logger logger = LogManager.getLogger();
Expand Down Expand Up @@ -152,10 +151,7 @@ void testPutPiecesByIdTest() throws Exception {
pieceRequest.put("receivingStatus", "Received");

addMockEntry(PIECES_STORAGE, pieceStorage);
verifyPut(String.format(PIECES_ID_PATH, pieceId), pieceRequest, "", 204)
.then()
.assertThat()
.body("statusUpdatedDate", notNullValue());;
verifyPut(String.format(PIECES_ID_PATH, pieceId), pieceRequest, "", 204);

// Message sent to event bus
HandlersTestHelper.verifyReceiptStatusUpdateEvent(1);
Expand Down
31 changes: 10 additions & 21 deletions src/test/java/org/folio/rest/impl/TitlesApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,20 @@
import static org.folio.TestUtils.getMockAsJson;
import static org.folio.TestUtils.getMockData;
import static org.folio.orders.utils.ResourcePathResolver.PO_LINES_STORAGE;
import static org.folio.orders.utils.ResourcePathResolver.TITLES;
import static org.folio.rest.impl.MockServer.TITLES_MOCK_DATA_PATH;
import static org.folio.rest.impl.MockServer.addMockEntry;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.Date;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;

import io.restassured.http.Header;
import io.vertx.core.json.JsonObject;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.folio.ApiTestSuite;
Expand All @@ -40,7 +42,6 @@
import org.folio.rest.acq.model.Title;
import org.folio.rest.jaxrs.model.CompositePoLine;
import org.folio.rest.jaxrs.model.Details;
import org.folio.rest.jaxrs.model.Errors;
import org.folio.rest.jaxrs.model.Physical;
import org.folio.rest.jaxrs.model.TitleCollection;
import org.hamcrest.Matchers;
Expand All @@ -51,9 +52,6 @@
import org.junit.jupiter.api.Test;
import org.mockito.MockitoAnnotations;

import io.restassured.http.Header;
import io.vertx.core.json.JsonObject;

public class TitlesApiTest {
private static final Logger logger = LogManager.getLogger();

Expand All @@ -63,6 +61,7 @@ public class TitlesApiTest {
static final String CONSISTENT_RECEIVED_STATUS_TITLE_UUID = "7d0aa803-a659-49f0-8a95-968f277c87d7";
public static final String SAMPLE_TITLE_ID = "9a665b22-9fe5-4c95-b4ee-837a5433c95d";
private final JsonObject titleJsonReqData = getMockAsJson(TITLES_MOCK_DATA_PATH + "title.json");
private final JsonObject packageTitleJsonReqData = getMockAsJson(TITLES_MOCK_DATA_PATH + "package_title.json");

private static boolean runningOnOwn;

Expand Down Expand Up @@ -124,35 +123,25 @@ void testPostTitle() {
int status500 = HttpStatus.HTTP_INTERNAL_SERVER_ERROR.toInt();
verifyPostResponse(TITLES_ENDPOINT, JsonObject.mapFrom(postTitleRq).encode(), prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, X_OKAPI_USER_ID,
new Header(X_ECHO_STATUS, String.valueOf(status500))), APPLICATION_JSON, status500);

addMockEntry(TITLES, JsonObject.mapFrom(postTitleRs));

Errors errors = verifyPostResponse(TITLES_ENDPOINT, JsonObject.mapFrom(postTitleRq).encode(),
prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, X_OKAPI_USER_ID), APPLICATION_JSON,
HttpStatus.HTTP_UNPROCESSABLE_ENTITY.toInt()).as(
Errors.class);

assertEquals("titleExist", errors.getErrors().get(0).getCode());
}

@Test
void titleShouldBePopulatedFromPackagePoLine() {

String packagePoLineId = UUID.randomUUID().toString();
String packageTitleName = "test title name";
String packageTestNumber = "test number";
Date packageExpectedDate = new Date();
String polNumbber = "1000-01";
String packageNote = "test note";

CompositePoLine packagePoLine = getMinimalContentCompositePoLine()
.withId(packagePoLineId)
.withTitleOrPackage(packageTitleName)
.withPoLineNumber(packageTestNumber)
.withPhysical(new Physical().withExpectedReceiptDate(packageExpectedDate))
.withPoLineNumber(polNumbber)
.withPhysical(new Physical().withExpectedReceiptDate(new Date()))
.withDetails(new Details().withReceivingNote(packageNote))
.withIsPackage(true);

Title titleWithPackagePoLineRQ = titleJsonReqData.mapTo(Title.class)
Title titleWithPackagePoLineRQ = packageTitleJsonReqData.mapTo(Title.class)
.withPoLineId(packagePoLineId);

addMockEntry(PO_LINES_STORAGE, JsonObject.mapFrom(packagePoLine));
Expand All @@ -161,8 +150,8 @@ void titleShouldBePopulatedFromPackagePoLine() {
prepareHeaders(EXIST_CONFIG_X_OKAPI_TENANT_LIMIT_10, X_OKAPI_USER_ID), APPLICATION_JSON, HttpStatus.HTTP_CREATED.toInt()).as(Title.class);

assertEquals(titleWithPackagePoLineRS.getPackageName(), packageTitleName);
assertEquals(titleWithPackagePoLineRS.getExpectedReceiptDate(), packageExpectedDate);
assertEquals(titleWithPackagePoLineRS.getPoLineNumber(), packageTestNumber);
assertNotNull(titleWithPackagePoLineRS.getExpectedReceiptDate());
assertEquals(titleWithPackagePoLineRS.getPoLineNumber(), polNumbber);
assertEquals(titleWithPackagePoLineRS.getReceivingNote(), packageNote);
}

Expand Down
16 changes: 16 additions & 0 deletions src/test/resources/mockdata/titles/package_title.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"title": "Sample Title",
"poLineId": "c0d08448-347b-418a-8c2f-5fb50248d67e",
"instanceId": "f1b57aeb-23c9-4386-bcb8-efda56878267",
"packageName": "test title name",
"expectedReceiptDate": "2020-10-08T03:53:00.000",
"poLineNumber": "1000-01",
"receivingNote": "test note",
"productIds": [
{
"productId": "9780764354113",
"productIdType": "8261054f-be78-422d-bd51-4ed9f33c3422",
"qualifier": "(paperback)"
}
]
}

0 comments on commit d121b59

Please sign in to comment.