diff --git a/actions/build.gradle b/actions/build.gradle index bcea1dd14..28b8da101 100644 --- a/actions/build.gradle +++ b/actions/build.gradle @@ -17,7 +17,7 @@ dependencies { testImplementation project(':fkq-test-utils') testImplementation project(':fkq-plugins') testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' } test { diff --git a/aws-ssm/build.gradle b/aws-ssm/build.gradle index 326454ddc..1994d10d3 100644 --- a/aws-ssm/build.gradle +++ b/aws-ssm/build.gradle @@ -14,7 +14,7 @@ dependencies { testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.7' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.4' testImplementation group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.12.770' } diff --git a/console/build.gradle b/console/build.gradle index 340b8703b..7b9f4c1ee 100644 --- a/console/build.gradle +++ b/console/build.gradle @@ -32,9 +32,9 @@ dependencies { testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.7' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.4' - testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.4' testImplementation group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.12.770' testImplementation group: 'com.microsoft.playwright', name: 'playwright', version: '1.46.0' } diff --git a/dynamodb-documents/build.gradle b/dynamodb-documents/build.gradle index 3e819e6cc..e5871b11c 100644 --- a/dynamodb-documents/build.gradle +++ b/dynamodb-documents/build.gradle @@ -35,8 +35,8 @@ dependencies { testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '2.0.7' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.4' testImplementation group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.12.770' configurations.all { diff --git a/fkq-lambda-core/build.gradle b/fkq-lambda-core/build.gradle index aa3f2bc57..86a74179d 100644 --- a/fkq-lambda-core/build.gradle +++ b/fkq-lambda-core/build.gradle @@ -19,8 +19,8 @@ dependencies { testImplementation project(':fkq-test-utils') testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.4' } test { diff --git a/fkq-test-utils/build.gradle b/fkq-test-utils/build.gradle index 1f0fff8b8..d119716b9 100644 --- a/fkq-test-utils/build.gradle +++ b/fkq-test-utils/build.gradle @@ -16,8 +16,8 @@ dependencies { api group: 'com.formkiq', name: 'client', version:'1.16.1-SNAPSHOT' implementation group: 'com.google.code.gson', name: 'gson', version: '2.11.0' implementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - implementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' - implementation group: 'org.testcontainers', name: 'localstack', version: '1.20.1' + implementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' + implementation group: 'org.testcontainers', name: 'localstack', version: '1.20.4' api group: 'org.mock-server', name: 'mockserver-netty', version: '5.15.0' implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.12.6' implementation group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.12.6' diff --git a/lambda-api/build.gradle b/lambda-api/build.gradle index 9ab057a30..910a2cfe4 100644 --- a/lambda-api/build.gradle +++ b/lambda-api/build.gradle @@ -61,14 +61,10 @@ dependencies { testImplementation group: 'commons-codec', name: 'commons-codec', version: '1.17.1' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.4' testImplementation group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.12.770' - testImplementation group: 'org.mock-server', name: 'mockserver-netty', version: '5.15.0' - - // TODO remove - testImplementation group: 'com.formkiq.stacks', name: 'client', version:'1.11.0' } compileJava { diff --git a/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/DocumentsDocumentIdOcrRequestTest.java b/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/DocumentsDocumentIdOcrRequestTest.java index e3d7c69ea..e827461ce 100644 --- a/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/DocumentsDocumentIdOcrRequestTest.java +++ b/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/DocumentsDocumentIdOcrRequestTest.java @@ -23,17 +23,22 @@ */ package com.formkiq.stacks.api.awstest; +import static com.formkiq.aws.dynamodb.objects.Objects.notNull; import static com.formkiq.testutils.aws.FkqDocumentService.addDocument; import static com.formkiq.testutils.aws.FkqDocumentService.waitForActions; import static com.formkiq.testutils.aws.FkqDocumentService.waitForDocumentContent; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.IOException; import java.io.InputStream; import java.net.URISyntaxException; -import java.util.Arrays; +import java.util.List; +import java.util.Objects; import java.util.concurrent.TimeUnit; + +import com.formkiq.client.model.DocumentAction; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import org.junit.jupiter.api.parallel.Execution; @@ -50,10 +55,8 @@ import com.formkiq.client.model.AddDocumentOcrResponse; import com.formkiq.client.model.DocumentActionStatus; import com.formkiq.client.model.DocumentActionType; -import com.formkiq.client.model.GetDocumentActionsResponse; import com.formkiq.client.model.GetDocumentOcrResponse; import com.formkiq.client.model.OcrEngine; -import com.formkiq.stacks.client.models.DocumentOcr; import com.formkiq.testutils.aws.AbstractAwsIntegrationTest; import software.amazon.awssdk.utils.IoUtils; @@ -73,11 +76,10 @@ public class DocumentsDocumentIdOcrRequestTest extends AbstractAwsIntegrationTes * @throws Exception Exception */ @Test - @Timeout(unit = TimeUnit.SECONDS, value = TEST_TIMEOUT) + @Timeout(value = TEST_TIMEOUT) public void testAddOcr01a() throws Exception { - String siteId = null; - ApiClient client = getApiClients(siteId).get(0); - addOcr01(client, siteId); + ApiClient client = getApiClients(null).get(0); + addOcr01(client, null); } /** @@ -86,7 +88,7 @@ public void testAddOcr01a() throws Exception { * @throws Exception Exception */ @Test - @Timeout(unit = TimeUnit.SECONDS, value = TEST_TIMEOUT) + @Timeout(value = TEST_TIMEOUT) public void testAddOcr01b() throws Exception { String siteId = SITE_ID; ApiClient client = getApiClients(siteId).get(0); @@ -109,6 +111,7 @@ private void addOcr01(final ApiClient client, final String siteId) assertEquals("OCR request submitted", response.getMessage()); GetDocumentOcrResponse documentOcr = getDocumentOcr(api, siteId, documentId); + assertNotNull(documentOcr.getData()); assertTrue(documentOcr.getData().contains("East Repair")); } @@ -118,12 +121,10 @@ private void addOcr01(final ApiClient client, final String siteId) * @throws Exception Exception */ @Test - @Timeout(unit = TimeUnit.SECONDS, value = TEST_TIMEOUT) + @Timeout(value = TEST_TIMEOUT) public void testAddOcr02a() throws Exception { - - String siteId = null; - ApiClient client = getApiClients(siteId).get(0); - addOcr02(client, siteId); + ApiClient client = getApiClients(null).get(0); + addOcr02(client, null); } /** @@ -132,7 +133,7 @@ public void testAddOcr02a() throws Exception { * @throws Exception Exception */ @Test - @Timeout(unit = TimeUnit.SECONDS, value = TEST_TIMEOUT) + @Timeout(value = TEST_TIMEOUT) public void testAddOcr02b() throws Exception { String siteId = SITE_ID; @@ -148,39 +149,39 @@ private void addOcr02(final ApiClient client, final String siteId) DocumentActionsApi actionsApi = new DocumentActionsApi(client); AddDocumentActionsRequest req = new AddDocumentActionsRequest() - .actions(Arrays.asList(new AddAction().type(DocumentActionType.OCR))); + .actions(List.of(new AddAction().type(DocumentActionType.OCR))); // when AddDocumentActionsResponse response = actionsApi.addDocumentActions(documentId, siteId, req); // then assertEquals("Actions saved", response.getMessage()); - waitForActions(client, siteId, documentId, Arrays.asList(DocumentActionStatus.COMPLETE)); + waitForActions(client, siteId, documentId, List.of(DocumentActionStatus.COMPLETE)); DocumentOcrApi api = new DocumentOcrApi(client); GetDocumentOcrResponse documentOcr = api.getDocumentOcr(documentId, siteId, null, null, null, null); + assertNotNull(documentOcr.getData()); assertTrue(documentOcr.getData().contains("East Repair")); - GetDocumentActionsResponse actions = - actionsApi.getDocumentActions(documentId, siteId, null, null, null); - assertEquals(1, actions.getActions().size()); - assertEquals("COMPLETE", actions.getActions().get(0).getStatus().name()); + List actions = + notNull(actionsApi.getDocumentActions(documentId, siteId, null, null, null).getActions()); + assertEquals(1, actions.size()); + assertEquals(DocumentActionStatus.COMPLETE, Objects.requireNonNull(actions.get(0).getStatus())); } /** - * Wait for {@link DocumentOcr} to have data. + * Wait for {@link DocumentOcrApi} to have data. * * @param api {@link DocumentOcrApi} * @param siteId {@link String} * @param documentId {@link String} * @return {@link GetDocumentOcrResponse} - * @throws IOException IOException * @throws InterruptedException InterruptedException * @throws ApiException ApiException */ private GetDocumentOcrResponse getDocumentOcr(final DocumentOcrApi api, final String siteId, - final String documentId) throws IOException, InterruptedException, ApiException { + final String documentId) throws InterruptedException, ApiException { GetDocumentOcrResponse documentOcr = api.getDocumentOcr(documentId, siteId, null, null, null, null); @@ -199,6 +200,7 @@ private GetDocumentOcrResponse getDocumentOcr(final DocumentOcrApi api, final St private byte[] toBytes(final String name) throws IOException { try (InputStream is = getClass().getResourceAsStream(name)) { + assertNotNull(is); return IoUtils.toByteArray(is); } } @@ -209,41 +211,41 @@ private byte[] toBytes(final String name) throws IOException { * @throws Exception Exception */ @Test - @Timeout(unit = TimeUnit.SECONDS, value = TEST_TIMEOUT) + @Timeout(value = TEST_TIMEOUT) public void testAddOcr03() throws Exception { - String siteId = null; - ApiClient client = getApiClients(siteId).get(0); + ApiClient client = getApiClients(null).get(0); byte[] content = toBytes("/multipage_example.pdf"); String documentId = - addDocument(client, siteId, "multipage_example.pdf", content, "application/pdf", null); - waitForDocumentContent(client, siteId, documentId); + addDocument(client, null, "multipage_example.pdf", content, "application/pdf", null); + waitForDocumentContent(client, null, documentId); DocumentActionsApi actionsApi = new DocumentActionsApi(client); AddDocumentActionsRequest req = new AddDocumentActionsRequest() - .actions(Arrays.asList(new AddAction().type(DocumentActionType.OCR).parameters( + .actions(List.of(new AddAction().type(DocumentActionType.OCR).parameters( new AddActionParameters().ocrEngine(OcrEngine.TESSERACT).ocrNumberOfPages("2")))); // when - AddDocumentActionsResponse response = actionsApi.addDocumentActions(documentId, siteId, req); + AddDocumentActionsResponse response = actionsApi.addDocumentActions(documentId, null, req); // then assertEquals("Actions saved", response.getMessage()); - waitForActions(client, siteId, documentId, Arrays.asList(DocumentActionStatus.COMPLETE)); + waitForActions(client, null, documentId, List.of(DocumentActionStatus.COMPLETE)); DocumentOcrApi api = new DocumentOcrApi(client); GetDocumentOcrResponse documentOcr = - api.getDocumentOcr(documentId, siteId, null, null, null, null); + api.getDocumentOcr(documentId, null, null, null, null, null); String text = documentOcr.getData(); + assertNotNull(text); assertTrue(text.contains("Your Company")); assertTrue(text.contains("2/9")); assertFalse(text.contains("3/9")); assertFalse(text.contains("Current process")); - GetDocumentActionsResponse actions = - actionsApi.getDocumentActions(documentId, siteId, null, null, null); - assertEquals(1, actions.getActions().size()); - assertEquals("COMPLETE", actions.getActions().get(0).getStatus().name()); + List actions = + notNull(actionsApi.getDocumentActions(documentId, null, null, null, null).getActions()); + assertEquals(1, actions.size()); + assertEquals(DocumentActionStatus.COMPLETE, actions.get(0).getStatus()); } } diff --git a/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/DocumentsRequestTest.java b/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/DocumentsRequestTest.java index 208abd677..1a53d5582 100644 --- a/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/DocumentsRequestTest.java +++ b/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/DocumentsRequestTest.java @@ -40,15 +40,12 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.http.HttpClient; -import java.net.http.HttpHeaders; import java.net.http.HttpRequest; import java.net.http.HttpRequest.BodyPublishers; import java.net.http.HttpResponse; import java.net.http.HttpResponse.BodyHandlers; -import java.nio.charset.StandardCharsets; import java.text.SimpleDateFormat; import java.util.Arrays; -import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Map; @@ -70,6 +67,9 @@ import com.formkiq.client.model.DocumentActionType; import com.formkiq.client.model.DocumentAttribute; import com.formkiq.client.model.GetAttributeResponse; +import com.formkiq.module.http.HttpHeaders; +import com.formkiq.module.http.HttpService; +import com.formkiq.module.http.HttpServiceJdk11; import com.formkiq.stacks.dynamodb.attributes.AttributeKeyReserved; import org.apache.commons.codec.digest.DigestUtils; import org.junit.jupiter.api.AfterAll; @@ -100,13 +100,9 @@ import com.formkiq.client.model.GetDocumentTagsResponse; import com.formkiq.client.model.GetDocumentsResponse; import com.formkiq.client.model.UpdateDocumentRequest; -import com.formkiq.stacks.client.HttpService; -import com.formkiq.stacks.client.HttpServiceJava; -import com.formkiq.stacks.client.models.AddDocument; import com.formkiq.stacks.dynamodb.ConfigService; import com.formkiq.testutils.aws.AbstractAwsIntegrationTest; import com.google.gson.Gson; -import software.amazon.awssdk.core.sync.RequestBody; /** * GET, OPTIONS, POST /documents. Tests. @@ -626,10 +622,6 @@ public void testPost05() throws Exception { ApiClient fclient = getApiClientForUser(FINANCE_EMAIL, USER_PASSWORD); DocumentsApi fapi = new DocumentsApi(fclient); - AddDocument post = new AddDocument(); - post.content("dummy data", StandardCharsets.UTF_8); - post.contentType("application/pdf"); - AddDocumentRequest req = new AddDocumentRequest().content("dummy data").contentType("application/pdf"); @@ -655,10 +647,6 @@ public void testPost06() throws Exception { // given configService.save(SITEID1, new DynamicObject(Map.of(MAX_DOCUMENTS, "1"))); - AddDocument post = new AddDocument(); - post.content("dummy data", StandardCharsets.UTF_8); - post.contentType("application/pdf"); - ApiClient c = getApiClients(SITEID1).get(0); DocumentsApi api = new DocumentsApi(c); AddDocumentRequest req = @@ -784,17 +772,16 @@ public void testPost08() throws Exception { ApiClient client = getApiClients(null).get(0); String url = client.getBasePath() + "/documents"; - Map> headers = - Map.of("Authorization", Collections.singletonList(getAdminToken().idToken())); - Optional o = Optional.of(HttpHeaders.of(headers, (t, u) -> true)); + Optional o = + Optional.of(new HttpHeaders().add("Authorization", getAdminToken().idToken())); String content = "{\"path\": \"test.txt\",\"contentType\":\"text/plain\"," + "\"content\":\"dGhpcyBpcyBhIHRlc3Q=\"," + "\"tags\":[{\"key\":\"author\",\"value\":\"Pierre Loti\"}]}"; // when - HttpService hs = new HttpServiceJava(); - HttpResponse response = hs.post(url, o, RequestBody.fromString(content)); + HttpService hs = new HttpServiceJdk11(); + HttpResponse response = hs.post(url, o, Optional.empty(), content); // then assertEquals(STATUS_CREATED, response.statusCode()); diff --git a/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/PrivateWebhooksRequestTest.java b/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/PrivateWebhooksRequestTest.java index 8b0af542e..8ff46ac00 100644 --- a/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/PrivateWebhooksRequestTest.java +++ b/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/PrivateWebhooksRequestTest.java @@ -29,13 +29,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; -import java.net.http.HttpHeaders; import java.net.http.HttpResponse; import java.util.List; import java.util.Map; import java.util.Optional; import com.formkiq.aws.dynamodb.ID; +import com.formkiq.module.http.HttpHeaders; +import com.formkiq.module.http.HttpService; +import com.formkiq.module.http.HttpServiceJdk11; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import com.formkiq.client.api.WebhooksApi; @@ -46,10 +48,7 @@ import com.formkiq.client.model.GetWebhookResponse; import com.formkiq.client.model.GetWebhooksResponse; import com.formkiq.lambda.apigateway.util.GsonUtil; -import com.formkiq.stacks.client.HttpService; -import com.formkiq.stacks.client.HttpServiceJava; import com.formkiq.testutils.aws.AbstractAwsIntegrationTest; -import software.amazon.awssdk.core.sync.RequestBody; /** * Process Urls. @@ -83,16 +82,13 @@ public void testPublicWebhooks01() throws Exception { String id = addWebhook.getWebhookId(); String urlpath = getRootHttpUrl() + "/private/webhooks/" + id; - Map> headers = Map.of("Authorization", - List.of(getAdminToken().idToken()), "Content-Type", List.of("text/plain")); - - Optional o = Optional.of(HttpHeaders.of(headers, (t, u) -> true)); + Optional o = Optional.of(new HttpHeaders().add("Content-Type", "text/plain")); String content = "{\"name\":\"John Smith\"}"; // when - HttpService hs = new HttpServiceJava(); - HttpResponse response = hs.post(urlpath, o, RequestBody.fromString(content)); + HttpService hs = new HttpServiceJdk11(); + HttpResponse response = hs.post(urlpath, o, Optional.empty(), content); // then assertEquals(STATUS_OK, response.statusCode()); @@ -137,15 +133,13 @@ public void testPublicWebhooks02() throws Exception { String id = addWebhook.getWebhookId(); String urlpath = getRootHttpUrl() + "/private/webhooks/" + id; - Map> headers = Map.of("Content-Type", List.of("text/plain")); - - Optional o = Optional.of(HttpHeaders.of(headers, (t, u) -> true)); + Optional o = Optional.of(new HttpHeaders().add("Content-Type", "text/plain")); String content = "{\"name\":\"John Smith\"}"; // when - HttpService hs = new HttpServiceJava(); - HttpResponse response = hs.post(urlpath, o, RequestBody.fromString(content)); + HttpService hs = new HttpServiceJdk11(); + HttpResponse response = hs.post(urlpath, o, Optional.empty(), content); // then assertEquals(STATUS_UNAUTHORIZED, response.statusCode()); diff --git a/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/PublicWebhooksRequestTest.java b/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/PublicWebhooksRequestTest.java index c3b46fe81..f5a2f32fc 100644 --- a/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/PublicWebhooksRequestTest.java +++ b/lambda-api/src/integration/java/com/formkiq/stacks/api/awstest/PublicWebhooksRequestTest.java @@ -29,12 +29,14 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; -import java.net.http.HttpHeaders; import java.net.http.HttpResponse; import java.util.List; import java.util.Map; import java.util.Optional; +import com.formkiq.module.http.HttpHeaders; +import com.formkiq.module.http.HttpService; +import com.formkiq.module.http.HttpServiceJdk11; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; import com.formkiq.aws.services.lambda.GsonUtil; @@ -46,10 +48,7 @@ import com.formkiq.client.model.GetDocumentResponse; import com.formkiq.client.model.GetWebhookResponse; import com.formkiq.client.model.GetWebhooksResponse; -import com.formkiq.stacks.client.HttpService; -import com.formkiq.stacks.client.HttpServiceJava; import com.formkiq.testutils.aws.AbstractAwsIntegrationTest; -import software.amazon.awssdk.core.sync.RequestBody; /** * Process Urls. @@ -84,17 +83,14 @@ public void testPublicWebhooks01() throws Exception { WebhooksApi api = new WebhooksApi(client); AddWebhookResponse addWebhook = api.addWebhook(new AddWebhookRequest().name("paypal"), null); String id = addWebhook.getWebhookId(); - // String id = client.addWebhook(new AddWebhookRequest().name("paypal")).id(); String urlpath = getRootHttpUrl() + "/public/webhooks/" + id; - Map> headers = Map.of("Content-Type", List.of("text/plain")); - Optional o = Optional.of(HttpHeaders.of(headers, (t, u) -> true)); - + Optional o = Optional.of(new HttpHeaders().add("Content-Type", "text/plain")); String content = "{\"name\":\"John Smith\"}"; // when - HttpService hs = new HttpServiceJava(); - HttpResponse response = hs.post(urlpath, o, RequestBody.fromString(content)); + HttpService hs = new HttpServiceJdk11(); + HttpResponse response = hs.post(urlpath, o, Optional.empty(), content); // then assertEquals(STATUS_OK, response.statusCode()); @@ -135,14 +131,13 @@ public void testPublicWebhooks02() throws Exception { // given String urlpath = getRootHttpUrl() + "/public/webhooks"; - Map> headers = Map.of("Content-Type", List.of("text/plain")); - Optional o = Optional.of(HttpHeaders.of(headers, (t, u) -> true)); + Optional o = Optional.of(new HttpHeaders().add("Content-Type", "text/plain")); String content = "{\"name\":\"John Smith\"}"; // when - HttpService hs = new HttpServiceJava(); - HttpResponse response = hs.post(urlpath, o, RequestBody.fromString(content)); + HttpService hs = new HttpServiceJdk11(); + HttpResponse response = hs.post(urlpath, o, Optional.empty(), content); // then assertEquals(STATUS_NOT_FOUND, response.statusCode()); @@ -160,14 +155,13 @@ public void testPublicWebhooks03() throws Exception { // given String urlpath = getRootHttpUrl() + "/public/webhooks/asdffgdfg"; - Map> headers = Map.of("Content-Type", List.of("text/plain")); - Optional o = Optional.of(HttpHeaders.of(headers, (t, u) -> true)); + Optional o = Optional.of(new HttpHeaders().add("Content-Type", "text/plain")); String content = "{\"name\":\"John Smith\"}"; // when - HttpService hs = new HttpServiceJava(); - HttpResponse response = hs.post(urlpath, o, RequestBody.fromString(content)); + HttpService hs = new HttpServiceJdk11(); + HttpResponse response = hs.post(urlpath, o, Optional.empty(), content); // then assertEquals(STATUS_BAD, response.statusCode()); @@ -190,14 +184,13 @@ public void testPublicWebhooks04() throws Exception { String id = addWebhook.getWebhookId(); String urlpath = getRootHttpUrl() + "/public/webhooks/" + id; - Map> headers = Map.of("Content-Type", List.of("text/plain")); - Optional o = Optional.of(HttpHeaders.of(headers, (t, u) -> true)); + Optional o = Optional.of(new HttpHeaders().add("Content-Type", "text/plain")); String content = "{\"name\":\"John Smith\"}"; // when - HttpService hs = new HttpServiceJava(); - HttpResponse response = hs.post(urlpath, o, RequestBody.fromString(content)); + HttpService hs = new HttpServiceJdk11(); + HttpResponse response = hs.post(urlpath, o, Optional.empty(), content); // then assertEquals(STATUS_UNAUTHORIZED, response.statusCode()); diff --git a/lambda-api/src/test/java/com/formkiq/stacks/api/ApiDocumentsUploadRequestTest.java b/lambda-api/src/test/java/com/formkiq/stacks/api/ApiDocumentsUploadRequestTest.java index 6931fb242..adc919afa 100644 --- a/lambda-api/src/test/java/com/formkiq/stacks/api/ApiDocumentsUploadRequestTest.java +++ b/lambda-api/src/test/java/com/formkiq/stacks/api/ApiDocumentsUploadRequestTest.java @@ -26,16 +26,9 @@ import com.formkiq.aws.dynamodb.DynamicObject; import com.formkiq.aws.dynamodb.ID; import com.formkiq.aws.dynamodb.model.DocumentItem; -import com.formkiq.aws.dynamodb.model.DocumentTag; import com.formkiq.aws.services.lambda.ApiGatewayRequestEvent; import com.formkiq.aws.services.lambda.ApiGatewayRequestEventBuilder; import com.formkiq.lambda.apigateway.util.GsonUtil; -import com.formkiq.module.actions.Action; -import com.formkiq.module.actions.ActionStatus; -import com.formkiq.module.actions.ActionType; -import com.formkiq.module.actions.services.ActionsService; -import com.formkiq.stacks.client.models.AddLargeDocument; -import com.formkiq.stacks.client.models.DocumentActionType; import com.formkiq.stacks.dynamodb.ConfigService; import com.formkiq.stacks.dynamodb.DocumentItemDynamoDb; import com.formkiq.testutils.aws.DynamoDbExtension; @@ -48,7 +41,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.Date; -import java.util.List; import java.util.Map; import static com.formkiq.aws.dynamodb.SiteIdKeyGenerator.DEFAULT_SITE_ID; @@ -63,8 +55,6 @@ @ExtendWith(LocalStackExtension.class) public class ApiDocumentsUploadRequestTest extends AbstractRequestHandler { - /** Results Limit. */ - private static final int LIMIT = 10; /** {@link ConfigService}. */ private ConfigService configService = null; @@ -360,112 +350,112 @@ public void testHandleGetDocumentsUpload07() throws Exception { } } - /** - * Valid POST generate upload document signed url. - * - * @throws Exception an error has occurred - */ - @Test - public void testHandlePostDocumentsUpload01() throws Exception { - // given - for (String siteId : Arrays.asList(null, ID.uuid())) { - String path = "/bleh/test.txt"; - - com.formkiq.stacks.client.models.DocumentTag tag0 = - new com.formkiq.stacks.client.models.DocumentTag().key("test").value("this"); - com.formkiq.stacks.client.models.AddDocumentAction action0 = - new com.formkiq.stacks.client.models.AddDocumentAction().type(DocumentActionType.OCR); - AddLargeDocument document = new AddLargeDocument().path(path) - .tags(Collections.singletonList(tag0)).actions(Collections.singletonList(action0)); - - ApiGatewayRequestEvent event = postDocumentsUploadRequest(siteId, - siteId != null ? siteId : DEFAULT_SITE_ID, GsonUtil.getInstance().toJson(document)); - - // when - String response = handleRequest(event); - - // then - Map m = GsonUtil.getInstance().fromJson(response, Map.class); - assertEquals("200.0", String.valueOf(m.get("statusCode"))); - ApiUrlResponse resp = expectResponse(response); - assertFalse(resp.getUrl().contains("content-length")); - - if (siteId != null) { - assertTrue(resp.getUrl().contains("/testbucket/" + siteId)); - } else { - assertFalse(resp.getUrl().contains("/testbucket/default")); - } - - String documentId = resp.getDocumentId(); - assertNotNull(document); - - ActionsService actionsService = getAwsServices().getExtension(ActionsService.class); - List actions = actionsService.getActions(siteId, documentId); - assertEquals(1, actions.size()); - assertEquals(ActionType.OCR, actions.get(0).type()); - assertEquals(ActionStatus.PENDING, actions.get(0).status()); - - int i = 0; - final int expectedCount = 1; - List tags = - getDocumentService().findDocumentTags(siteId, documentId, null, LIMIT).getResults(); - assertEquals(expectedCount, tags.size()); - assertEquals("test", tags.get(i).getKey()); - assertEquals("this", tags.get(i).getValue()); - - assertNotNull(getDocumentService().findMostDocumentDate()); - } - } - - /** - * Valid POST generate upload document signed url. - * - * @throws Exception an error has occurred - */ - @Test - public void testHandlePostDocumentsUpload03() throws Exception { - // given - for (String siteId : Arrays.asList(null, ID.uuid())) { - String tagSchemaId = ID.uuid(); - ApiGatewayRequestEvent event = - toRequestEvent("/request-get-documents-upload-documentid.json"); - event.setHttpMethod("POST"); - addParameter(event, "siteId", siteId); - com.formkiq.stacks.client.models.DocumentTag tag0 = - new com.formkiq.stacks.client.models.DocumentTag().key("test").value("this"); - AddLargeDocument document = - new AddLargeDocument().tagSchemaId(tagSchemaId).tags(Collections.singletonList(tag0)); - event.setBody(GsonUtil.getInstance().toJson(document)); - event.setIsBase64Encoded(Boolean.FALSE); - - // when - String response = handleRequest(event); - - // then - Map m = GsonUtil.getInstance().fromJson(response, Map.class); - assertEquals("200.0", String.valueOf(m.get("statusCode"))); - ApiUrlResponse resp = expectResponse(response); - - if (siteId != null) { - assertTrue(resp.getUrl().contains("/testbucket/" + siteId)); - } else { - assertFalse(resp.getUrl().contains("/testbucket/default")); - } - - String documentId = resp.getDocumentId(); - assertNotNull(document); - - int i = 0; - final int expectedCount = 1; - List tags = - getDocumentService().findDocumentTags(siteId, documentId, null, LIMIT).getResults(); - assertEquals(expectedCount, tags.size()); - assertEquals("test", tags.get(i).getKey()); - assertEquals("this", tags.get(i).getValue()); - - assertNotNull(getDocumentService().findMostDocumentDate()); - } - } + // /** + // * Valid POST generate upload document signed url. + // * + // * @throws Exception an error has occurred + // */ + // @Test + // public void testHandlePostDocumentsUpload01() throws Exception { + // // given + // for (String siteId : Arrays.asList(null, ID.uuid())) { + // String path = "/bleh/test.txt"; + // + //// com.formkiq.stacks.client.models.DocumentTag tag0 = + //// new com.formkiq.stacks.client.models.DocumentTag().key("test").value("this"); + //// com.formkiq.stacks.client.models.AddDocumentAction action0 = + //// new com.formkiq.stacks.client.models.AddDocumentAction().type(DocumentActionType.OCR); + //// AddLargeDocument document = new AddLargeDocument().path(path) + //// .tags(Collections.singletonList(tag0)).actions(Collections.singletonList(action0)); + //// + //// ApiGatewayRequestEvent event = postDocumentsUploadRequest(siteId, + //// siteId != null ? siteId : DEFAULT_SITE_ID, GsonUtil.getInstance().toJson(document)); + // + // // when + //// String response = handleRequest(event); + // + // // then + //// Map m = GsonUtil.getInstance().fromJson(response, Map.class); + //// assertEquals("200.0", String.valueOf(m.get("statusCode"))); + //// ApiUrlResponse resp = expectResponse(response); + //// assertFalse(resp.getUrl().contains("content-length")); + //// + //// if (siteId != null) { + //// assertTrue(resp.getUrl().contains("/testbucket/" + siteId)); + //// } else { + //// assertFalse(resp.getUrl().contains("/testbucket/default")); + //// } + // + //// String documentId = resp.getDocumentId(); + //// assertNotNull(document); + // + //// ActionsService actionsService = getAwsServices().getExtension(ActionsService.class); + //// List actions = actionsService.getActions(siteId, documentId); + //// assertEquals(1, actions.size()); + //// assertEquals(ActionType.OCR, actions.get(0).type()); + //// assertEquals(ActionStatus.PENDING, actions.get(0).status()); + // + // int i = 0; + // final int expectedCount = 1; + // List tags = + // getDocumentService().findDocumentTags(siteId, documentId, null, LIMIT).getResults(); + // assertEquals(expectedCount, tags.size()); + // assertEquals("test", tags.get(i).getKey()); + // assertEquals("this", tags.get(i).getValue()); + // + // assertNotNull(getDocumentService().findMostDocumentDate()); + // } + // } + + // /** + // * Valid POST generate upload document signed url. + // * + // * @throws Exception an error has occurred + // */ + // @Test + // public void testHandlePostDocumentsUpload03() throws Exception { + // // given + // for (String siteId : Arrays.asList(null, ID.uuid())) { + // String tagSchemaId = ID.uuid(); + // ApiGatewayRequestEvent event = + // toRequestEvent("/request-get-documents-upload-documentid.json"); + // event.setHttpMethod("POST"); + // addParameter(event, "siteId", siteId); + // com.formkiq.stacks.client.models.DocumentTag tag0 = + // new com.formkiq.stacks.client.models.DocumentTag().key("test").value("this"); + // AddLargeDocument document = + // new AddLargeDocument().tagSchemaId(tagSchemaId).tags(Collections.singletonList(tag0)); + // event.setBody(GsonUtil.getInstance().toJson(document)); + // event.setIsBase64Encoded(Boolean.FALSE); + // + // // when + // String response = handleRequest(event); + // + // // then + // Map m = GsonUtil.getInstance().fromJson(response, Map.class); + // assertEquals("200.0", String.valueOf(m.get("statusCode"))); + // ApiUrlResponse resp = expectResponse(response); + // + // if (siteId != null) { + // assertTrue(resp.getUrl().contains("/testbucket/" + siteId)); + // } else { + // assertFalse(resp.getUrl().contains("/testbucket/default")); + // } + // + // String documentId = resp.getDocumentId(); + // assertNotNull(document); + // + // int i = 0; + // final int expectedCount = 1; + // List tags = + // getDocumentService().findDocumentTags(siteId, documentId, null, LIMIT).getResults(); + // assertEquals(expectedCount, tags.size()); + // assertEquals("test", tags.get(i).getKey()); + // assertEquals("this", tags.get(i).getValue()); + // + // assertNotNull(getDocumentService().findMostDocumentDate()); + // } + // } /** * Valid readonly user generate upload document signed url. @@ -494,33 +484,33 @@ public void testHandlePostDocumentsUpload04() throws Exception { } } - /** - * Valid POST /documents/upload, invalid tag. - * - * @throws Exception an error has occurred - */ - @Test - public void testHandlePostDocumentsUpload05() throws Exception { - // given - for (String siteId : Arrays.asList(null, ID.uuid())) { - - com.formkiq.stacks.client.models.DocumentTag tag0 = - new com.formkiq.stacks.client.models.DocumentTag().key("CLAMAV_SCAN_TIMESTAMP") - .value("this"); - AddLargeDocument document = new AddLargeDocument().tags(Collections.singletonList(tag0)); - - ApiGatewayRequestEvent event = postDocumentsUploadRequest(siteId, - siteId != null ? siteId : DEFAULT_SITE_ID, GsonUtil.getInstance().toJson(document)); - - // when - String response = handleRequest(event); - - // then - Map m = GsonUtil.getInstance().fromJson(response, Map.class); - assertEquals("400.0", String.valueOf(m.get("statusCode"))); - assertEquals( - "{\"errors\":[{\"key\":\"CLAMAV_SCAN_TIMESTAMP\",\"error\":\"unallowed tag key\"}]}", - String.valueOf(m.get("body"))); - } - } + // /** + // * Valid POST /documents/upload, invalid tag. + // * + // * @throws Exception an error has occurred + // */ + // @Test + // public void testHandlePostDocumentsUpload05() throws Exception { + // // given + // for (String siteId : Arrays.asList(null, ID.uuid())) { + // + // com.formkiq.stacks.client.models.DocumentTag tag0 = + // new com.formkiq.stacks.client.models.DocumentTag().key("CLAMAV_SCAN_TIMESTAMP") + // .value("this"); + // AddLargeDocument document = new AddLargeDocument().tags(Collections.singletonList(tag0)); + // + // ApiGatewayRequestEvent event = postDocumentsUploadRequest(siteId, + // siteId != null ? siteId : DEFAULT_SITE_ID, GsonUtil.getInstance().toJson(document)); + // + // // when + // String response = handleRequest(event); + // + // // then + // Map m = GsonUtil.getInstance().fromJson(response, Map.class); + // assertEquals("400.0", String.valueOf(m.get("statusCode"))); + // assertEquals( + // "{\"errors\":[{\"key\":\"CLAMAV_SCAN_TIMESTAMP\",\"error\":\"unallowed tag key\"}]}", + // String.valueOf(m.get("body"))); + // } + // } } diff --git a/lambda-api/src/test/java/com/formkiq/stacks/api/handler/DocumentsIdRequestTest.java b/lambda-api/src/test/java/com/formkiq/stacks/api/handler/DocumentsIdRequestTest.java index fdacfacfc..eca31fd9e 100644 --- a/lambda-api/src/test/java/com/formkiq/stacks/api/handler/DocumentsIdRequestTest.java +++ b/lambda-api/src/test/java/com/formkiq/stacks/api/handler/DocumentsIdRequestTest.java @@ -31,13 +31,11 @@ import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; -import java.net.http.HttpHeaders; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Optional; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import com.formkiq.aws.dynamodb.DbKeys; import com.formkiq.aws.dynamodb.ID; @@ -58,8 +56,9 @@ import com.formkiq.client.model.SearchResultDocument; import com.formkiq.client.model.SetSitesSchemaRequest; import com.formkiq.client.model.UpdateDocumentRequest; -import com.formkiq.stacks.client.HttpService; -import com.formkiq.stacks.client.HttpServiceJava; +import com.formkiq.module.http.HttpHeaders; +import com.formkiq.module.http.HttpService; +import com.formkiq.module.http.HttpServiceJdk11; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Timeout; @@ -73,7 +72,6 @@ import com.formkiq.client.model.GetDocumentResponse; import com.formkiq.client.model.GetDocumentUrlResponse; import com.formkiq.client.model.SetDocumentRestoreResponse; -import software.amazon.awssdk.core.sync.RequestBody; /** Unit Tests for request /documents/{documentId}. */ public class DocumentsIdRequestTest extends AbstractApiClientRequestTest { @@ -901,7 +899,7 @@ public void testUpdate10() throws ApiException { * @throws ApiException ApiException */ @Test - public void testUpdate11() throws ApiException, IOException, InterruptedException { + public void testUpdate11() throws ApiException, IOException { // given final String content0 = "dummy data"; final String checksum0 = "797bb0abff798d7200af7685dca7901edffc52bf26500d5bd97282658ee24152"; @@ -1011,15 +1009,13 @@ public void testUpdate12() throws Exception { } private void putS3Request(final String presignedUrl, final Map headerMap, - final String content) throws IOException, InterruptedException { + final String content) throws IOException { - HttpService http = new HttpServiceJava(); - RequestBody payload = RequestBody.fromString(content); + HttpService http = new HttpServiceJdk11(); - Map> headers = headerMap.entrySet().stream() - .collect(Collectors.toMap(Map.Entry::getKey, entry -> List.of((String) entry.getValue()))); + HttpHeaders hds = new HttpHeaders(); + headerMap.forEach((h, v) -> hds.add(h, v.toString())); - Optional o = Optional.of(HttpHeaders.of(headers, (t, u) -> true)); - http.put(presignedUrl, o, payload); + http.put(presignedUrl, Optional.of(hds), Optional.empty(), content); } } diff --git a/lambda-api/src/test/java/com/formkiq/stacks/api/handler/DocumentsUploadRequestTest.java b/lambda-api/src/test/java/com/formkiq/stacks/api/handler/DocumentsUploadRequestTest.java index c42b7e3fd..01f235f6d 100644 --- a/lambda-api/src/test/java/com/formkiq/stacks/api/handler/DocumentsUploadRequestTest.java +++ b/lambda-api/src/test/java/com/formkiq/stacks/api/handler/DocumentsUploadRequestTest.java @@ -26,31 +26,29 @@ import com.formkiq.aws.dynamodb.ID; import com.formkiq.aws.services.lambda.ApiResponseStatus; import com.formkiq.client.invoker.ApiException; +import com.formkiq.client.model.AddAction; import com.formkiq.client.model.AddDocumentRequest; import com.formkiq.client.model.AddDocumentTag; import com.formkiq.client.model.AddDocumentUploadRequest; import com.formkiq.client.model.ChecksumType; +import com.formkiq.client.model.DocumentAction; +import com.formkiq.client.model.DocumentActionStatus; +import com.formkiq.client.model.DocumentActionType; import com.formkiq.client.model.DocumentTag; import com.formkiq.client.model.GetDocumentResponse; import com.formkiq.client.model.GetDocumentTagsResponse; import com.formkiq.client.model.GetDocumentUrlResponse; import com.formkiq.client.model.UpdateConfigurationRequest; -import com.formkiq.stacks.client.HttpService; -import com.formkiq.stacks.client.HttpServiceJava; -import com.formkiq.testutils.aws.DynamoDbExtension; -import com.formkiq.testutils.aws.LocalStackExtension; +import com.formkiq.module.http.HttpHeaders; +import com.formkiq.module.http.HttpService; +import com.formkiq.module.http.HttpServiceJdk11; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import software.amazon.awssdk.core.sync.RequestBody; import java.io.IOException; -import java.net.http.HttpHeaders; import java.net.http.HttpResponse; import java.util.Arrays; import java.util.List; -import java.util.Map; import java.util.Optional; -import java.util.stream.Collectors; import static com.formkiq.aws.dynamodb.SiteIdKeyGenerator.DEFAULT_SITE_ID; import static com.formkiq.aws.dynamodb.objects.Objects.notNull; @@ -58,11 +56,10 @@ import static com.formkiq.aws.services.lambda.ApiResponseStatus.SC_NOT_FOUND; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; /** Unit Tests for request /documents/upload, /documents/{documentId}/upload . */ -@ExtendWith(DynamoDbExtension.class) -@ExtendWith(LocalStackExtension.class) public class DocumentsUploadRequestTest extends AbstractApiClientRequestTest { /** @@ -217,10 +214,9 @@ public void testGet05() throws Exception { /** * Get Request Upload Document Url, invalid documentId. * - * @throws Exception Exception */ @Test - public void testGetUpload01() throws Exception { + public void testGetUpload01() { // given for (String siteId : Arrays.asList(DEFAULT_SITE_ID, ID.uuid())) { @@ -635,15 +631,79 @@ public void testPost08() throws Exception { } } + /** + * Valid POST generate upload document signed url. + * + * @throws Exception Exception + */ + @Test + public void testPost09() throws Exception { + // given + for (String siteId : Arrays.asList(null, ID.uuid())) { + + setBearerToken(siteId); + AddDocumentUploadRequest req = + new AddDocumentUploadRequest().addTagsItem(new AddDocumentTag().key("test").value("this")) + .addActionsItem(new AddAction().type(DocumentActionType.OCR)); + + // when + GetDocumentUrlResponse response = + this.documentsApi.addDocumentUpload(req, siteId, 1, null, null); + + // then + String url = response.getUrl(); + assertNotNull(url); + assertTrue( + siteId != null ? url.contains("/testbucket/" + siteId) : url.contains("/testbucket/")); + + String documentId = response.getDocumentId(); + List actions = notNull(this.documentActionsApi + .getDocumentActions(documentId, siteId, null, null, null).getActions()); + assertEquals(1, actions.size()); + assertEquals(DocumentActionType.OCR, actions.get(0).getType()); + assertEquals(DocumentActionStatus.PENDING, actions.get(0).getStatus()); + + List tags = notNull( + this.tagsApi.getDocumentTags(documentId, siteId, null, null, null, null).getTags()); + assertEquals(1, tags.size()); + assertEquals("test", tags.get(0).getKey()); + assertEquals("this", tags.get(0).getValue()); + } + } + + /** + * Valid POST generate upload document signed url. + * + */ + @Test + public void testPost10() { + // given + for (String siteId : Arrays.asList(DEFAULT_SITE_ID, ID.uuid())) { + + setBearerToken(siteId); + AddDocumentUploadRequest req = new AddDocumentUploadRequest() + .addTagsItem(new AddDocumentTag().key("CLAMAV_SCAN_TIMESTAMP").value("this")); + + // when + try { + this.documentsApi.addDocumentUpload(req, siteId, 1, null, null); + fail(); + } catch (ApiException e) { + // then + assertEquals(SC_BAD_REQUEST.getStatusCode(), e.getCode()); + assertEquals("{\"errors\":[{\"key\":\"CLAMAV_SCAN_TIMESTAMP\"," + + "\"error\":\"unallowed tag key\"}]}", e.getResponseBody()); + } + } + } + private HttpResponse putS3Request(final GetDocumentUrlResponse response, - final String content) throws IOException, InterruptedException { - HttpService http = new HttpServiceJava(); - RequestBody payload = RequestBody.fromString(content); + final String content) throws IOException { + HttpService http = new HttpServiceJdk11(); - Map> headers = notNull(response.getHeaders()).entrySet().stream() - .collect(Collectors.toMap(Map.Entry::getKey, entry -> List.of((String) entry.getValue()))); + HttpHeaders hds = new HttpHeaders(); + notNull(response.getHeaders()).forEach((h, v) -> hds.add(h, v.toString())); - Optional o = Optional.of(HttpHeaders.of(headers, (t, u) -> true)); - return http.put(response.getUrl(), o, payload); + return http.put(response.getUrl(), Optional.of(hds), Optional.empty(), content); } } diff --git a/lambda-apikey-authorizer/build.gradle b/lambda-apikey-authorizer/build.gradle index ed00ef05c..c40a3b0c1 100644 --- a/lambda-apikey-authorizer/build.gradle +++ b/lambda-apikey-authorizer/build.gradle @@ -22,8 +22,8 @@ dependencies { testImplementation project(':fkq-test-utils') testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.4' } compileJava { diff --git a/lambda-ocr-tesseract/build.gradle b/lambda-ocr-tesseract/build.gradle index 766604405..54ad99a27 100644 --- a/lambda-ocr-tesseract/build.gradle +++ b/lambda-ocr-tesseract/build.gradle @@ -28,9 +28,9 @@ dependencies { testImplementation project(':fkq-test-utils') testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.4' } test { diff --git a/lambda-s3/build.gradle b/lambda-s3/build.gradle index 639d68ece..715a1756f 100644 --- a/lambda-s3/build.gradle +++ b/lambda-s3/build.gradle @@ -51,11 +51,10 @@ dependencies { testImplementation group: 'software.amazon.awssdk', name: 's3', version: '2.27.18' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.4' testImplementation group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.12.770' - testImplementation group: 'org.mock-server', name: 'mockserver-netty', version: '5.15.0' } compileJava { diff --git a/lambda-s3/src/test/java/com/formkiq/stacks/lambda/s3/DocumentActionsProcessorTest.java b/lambda-s3/src/test/java/com/formkiq/stacks/lambda/s3/DocumentActionsProcessorTest.java index 26bd0c2fb..51d9058ae 100644 --- a/lambda-s3/src/test/java/com/formkiq/stacks/lambda/s3/DocumentActionsProcessorTest.java +++ b/lambda-s3/src/test/java/com/formkiq/stacks/lambda/s3/DocumentActionsProcessorTest.java @@ -98,7 +98,6 @@ import com.formkiq.validation.ValidationException; import com.google.gson.Gson; import joptsimple.internal.Strings; -import org.jetbrains.annotations.NotNull; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -368,7 +367,7 @@ private static void initProcessor(final String module, final String chatgptUrl) eventBridgeService = serviceCache.getExtension(EventBridgeService.class); } - private static @NotNull Map buildEnvironment(final String module, + private static Map buildEnvironment(final String module, final String chatgptUrl) { Map env = new HashMap<>(); env.put("AWS_REGION", AWS_REGION.toString()); diff --git a/lambda-typesense/build.gradle b/lambda-typesense/build.gradle index 9d43c0f0e..e5db6f300 100644 --- a/lambda-typesense/build.gradle +++ b/lambda-typesense/build.gradle @@ -33,9 +33,9 @@ dependencies { testImplementation project(':fkq-test-utils') testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.1' - testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'junit-jupiter', version: '1.20.4' + testImplementation group: 'org.testcontainers', name: 'localstack', version: '1.20.4' } compileJava { diff --git a/netty-server/build.gradle b/netty-server/build.gradle index 89c540590..922838724 100644 --- a/netty-server/build.gradle +++ b/netty-server/build.gradle @@ -30,7 +30,7 @@ dependencies { testImplementation project(':fkq-test-utils') testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' } test { diff --git a/typesense/build.gradle b/typesense/build.gradle index 6193ee43c..42e155e11 100644 --- a/typesense/build.gradle +++ b/typesense/build.gradle @@ -6,7 +6,7 @@ dependencies { implementation project(':fkq-lambda-services') testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.11.0' - testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.1' + testImplementation group: 'org.testcontainers', name: 'testcontainers', version: '1.20.4' testImplementation project(':fkq-test-utils') }