Skip to content

Commit

Permalink
Added ClassificationId to GET /sites/:siteId/classifications
Browse files Browse the repository at this point in the history
  • Loading branch information
mfriesen committed Jul 11, 2024
1 parent 43a3291 commit 759ace8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion fkq-test-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dependencies {

implementation group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.12.646'
implementation group: 'com.amazonaws', name: 'aws-lambda-java-core', version: '1.2.3'
api group: 'com.formkiq', name: 'client', version:'1.15.0'
api group: 'com.formkiq', name: 'client', version:'1.15.1'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
implementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version:'5.10.1'
implementation group: 'org.testcontainers', name: 'testcontainers', version: '1.19.4'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@ public ApiRequestHandlerResponse get(final LambdaLogger logger,
PaginationResults<ClassificationRecord> results =
service.findAllClassifications(siteId, startkey, limit);

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

ApiPagination current =
createPagination(cacheService, event, pagination, results.getToken(), limit);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
Expand All @@ -63,6 +64,7 @@
import static com.formkiq.testutils.aws.FkqAttributeService.createStringAttribute;
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 /sites/{siteId}/schema/document. */
Expand All @@ -88,10 +90,14 @@ public void testGetClassifications01() throws ApiException {

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

List<String> ids = new ArrayList<>();

for (int i = 0; i < count; i++) {
AddClassificationRequest req = new AddClassificationRequest()
.classification(new AddClassification().name("test_" + i).attributes(attr0));
this.schemasApi.addClassification(siteId, req);
String classificationId =
this.schemasApi.addClassification(siteId, req).getClassificationId();
ids.add(classificationId);
}

// when
Expand All @@ -102,6 +108,7 @@ public void testGetClassifications01() throws ApiException {
// then
int i = 0;
assertEquals(limit, attributes.size());
assertTrue(ids.contains(attributes.get(i).getClassificationId()));
assertEquals("joesmith", attributes.get(i).getUserId());
assertNotNull(attributes.get(i).getInsertedDate());
assertEquals("test_0", attributes.get(i++).getName());
Expand Down

0 comments on commit 759ace8

Please sign in to comment.