Skip to content

Commit 759ace8

Browse files
committed
Added ClassificationId to GET /sites/:siteId/classifications
1 parent 43a3291 commit 759ace8

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

fkq-test-utils/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies {
1313

1414
implementation group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.12.646'
1515
implementation group: 'com.amazonaws', name: 'aws-lambda-java-core', version: '1.2.3'
16-
api group: 'com.formkiq', name: 'client', version:'1.15.0'
16+
api group: 'com.formkiq', name: 'client', version:'1.15.1'
1717
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
1818
implementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.10.1'
1919
implementation group: 'org.testcontainers', name: 'testcontainers', version: '1.19.4'

lambda-api/src/main/java/com/formkiq/stacks/api/handler/SitesClassificationRequestHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,11 @@ public ApiRequestHandlerResponse get(final LambdaLogger logger,
7373
PaginationResults<ClassificationRecord> results =
7474
service.findAllClassifications(siteId, startkey, limit);
7575

76-
List<?> data = results.getResults().stream().map(c -> Map.of("name", c.getName(), "userId",
77-
c.getUserId(), "insertedDate", c.getInsertedDate())).toList();
76+
List<?> data =
77+
results
78+
.getResults().stream().map(c -> Map.of("classificationId", c.getDocumentId(), "name",
79+
c.getName(), "userId", c.getUserId(), "insertedDate", c.getInsertedDate()))
80+
.toList();
7881

7982
ApiPagination current =
8083
createPagination(cacheService, event, pagination, results.getToken(), limit);

lambda-api/src/test/java/com/formkiq/stacks/api/handler/SitesClassificationsRequestTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.junit.jupiter.api.Test;
5656
import org.junit.jupiter.api.extension.ExtendWith;
5757

58+
import java.util.ArrayList;
5859
import java.util.Arrays;
5960
import java.util.List;
6061
import java.util.UUID;
@@ -63,6 +64,7 @@
6364
import static com.formkiq.testutils.aws.FkqAttributeService.createStringAttribute;
6465
import static org.junit.jupiter.api.Assertions.assertEquals;
6566
import static org.junit.jupiter.api.Assertions.assertNotNull;
67+
import static org.junit.jupiter.api.Assertions.assertTrue;
6668
import static org.junit.jupiter.api.Assertions.fail;
6769

6870
/** Unit Tests for request /sites/{siteId}/schema/document. */
@@ -88,10 +90,14 @@ public void testGetClassifications01() throws ApiException {
8890

8991
SchemaAttributes attr0 = createSchemaAttributes(List.of("invoice"), null);
9092

93+
List<String> ids = new ArrayList<>();
94+
9195
for (int i = 0; i < count; i++) {
9296
AddClassificationRequest req = new AddClassificationRequest()
9397
.classification(new AddClassification().name("test_" + i).attributes(attr0));
94-
this.schemasApi.addClassification(siteId, req);
98+
String classificationId =
99+
this.schemasApi.addClassification(siteId, req).getClassificationId();
100+
ids.add(classificationId);
95101
}
96102

97103
// when
@@ -102,6 +108,7 @@ public void testGetClassifications01() throws ApiException {
102108
// then
103109
int i = 0;
104110
assertEquals(limit, attributes.size());
111+
assertTrue(ids.contains(attributes.get(i).getClassificationId()));
105112
assertEquals("joesmith", attributes.get(i).getUserId());
106113
assertNotNull(attributes.get(i).getInsertedDate());
107114
assertEquals("test_0", attributes.get(i++).getName());

0 commit comments

Comments
 (0)