Skip to content

Commit

Permalink
removed DocumentEventService
Browse files Browse the repository at this point in the history
  • Loading branch information
mfriesen committed Jul 30, 2023
1 parent 54eb09c commit 1f88cd5
Show file tree
Hide file tree
Showing 13 changed files with 23 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,12 @@
import com.formkiq.aws.dynamodb.model.DocumentItem;
import com.formkiq.module.actions.services.ActionsService;
import com.formkiq.module.actions.services.ActionsServiceDynamoDb;
import com.formkiq.module.events.EventService;
import com.formkiq.module.events.EventServiceSns;
import com.formkiq.stacks.dynamodb.DocumentItemDynamoDb;
import com.formkiq.stacks.dynamodb.DocumentService;
import com.formkiq.stacks.dynamodb.DocumentServiceImpl;
import com.formkiq.stacks.dynamodb.DocumentVersionServiceNoVersioning;
import com.formkiq.testutils.aws.DynamoDbExtension;
import com.formkiq.testutils.aws.DynamoDbTestServices;
import com.formkiq.testutils.aws.TestServices;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;

/** Unit Tests for {@link ActionsServiceDynamoDbTest}. */
Expand All @@ -70,10 +67,8 @@ public static void beforeAll() throws Exception {

DynamoDbConnectionBuilder db = DynamoDbTestServices.getDynamoDbConnection();
service = new ActionsServiceDynamoDb(db, DOCUMENTS_TABLE);
EventService documentEventService =
new EventServiceSns(TestServices.getSnsConnection(null), "");
documentService = new DocumentServiceImpl(db, DOCUMENTS_TABLE,
new DocumentVersionServiceNoVersioning(), documentEventService);
documentService =
new DocumentServiceImpl(db, DOCUMENTS_TABLE, new DocumentVersionServiceNoVersioning());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package com.formkiq.stacks.dynamodb;

import com.formkiq.aws.dynamodb.DynamoDbConnectionBuilder;
import com.formkiq.module.events.EventService;
import com.formkiq.module.lambdaservices.AwsServiceCache;
import com.formkiq.module.lambdaservices.AwsServiceExtension;
import com.formkiq.plugins.tagschema.DocumentTagSchemaPlugin;
Expand Down Expand Up @@ -55,10 +54,8 @@ public DocumentSearchService loadService(final AwsServiceCache awsServiceCache)
awsServiceCache.getExtension(DynamoDbConnectionBuilder.class);
DocumentService documentService = awsServiceCache.getExtension(DocumentService.class);

EventService eventService = awsServiceCache.getExtension(EventService.class);

this.service = new DocumentSearchServiceImpl(connection, documentService,
awsServiceCache.environment("DOCUMENTS_TABLE"), documentTagSchemaPlugin, eventService);
awsServiceCache.environment("DOCUMENTS_TABLE"), documentTagSchemaPlugin);
}

return this.service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import com.formkiq.aws.dynamodb.model.SearchQuery;
import com.formkiq.aws.dynamodb.model.SearchTagCriteria;
import com.formkiq.aws.dynamodb.objects.Objects;
import com.formkiq.module.events.EventService;
import com.formkiq.plugins.tagschema.DocumentTagSchemaPlugin;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
Expand Down Expand Up @@ -99,11 +98,10 @@ public class DocumentSearchServiceImpl implements DocumentSearchService {
* @param documentService {@link DocumentService}
* @param documentsTable {@link String}
* @param plugin {@link DocumentTagSchemaPlugin}
* @param documentEventService {@link EventService}
*/
public DocumentSearchServiceImpl(final DynamoDbConnectionBuilder connection,
final DocumentService documentService, final String documentsTable,
final DocumentTagSchemaPlugin plugin, final EventService documentEventService) {
final DocumentTagSchemaPlugin plugin) {

this.dbClient = connection.build();
this.docService = documentService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package com.formkiq.stacks.dynamodb;

import com.formkiq.aws.dynamodb.DynamoDbConnectionBuilder;
import com.formkiq.module.events.EventService;
import com.formkiq.module.lambdaservices.AwsServiceCache;
import com.formkiq.module.lambdaservices.AwsServiceExtension;

Expand Down Expand Up @@ -52,9 +51,8 @@ public DocumentService loadService(final AwsServiceCache awsServiceCache) {
DocumentVersionService versionService =
awsServiceCache.getExtension(DocumentVersionService.class);

EventService documentEventService = awsServiceCache.getExtension(EventService.class);
this.service = new DocumentServiceImpl(connection,
awsServiceCache.environment("DOCUMENTS_TABLE"), versionService, documentEventService);
awsServiceCache.environment("DOCUMENTS_TABLE"), versionService);
}

return this.service;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import com.formkiq.aws.dynamodb.model.DynamicDocumentItem;
import com.formkiq.aws.dynamodb.objects.DateUtil;
import com.formkiq.aws.dynamodb.objects.Objects;
import com.formkiq.module.events.EventService;
import software.amazon.awssdk.services.dynamodb.DynamoDbClient;
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import software.amazon.awssdk.services.dynamodb.model.BatchGetItemRequest;
Expand Down Expand Up @@ -116,11 +115,9 @@ public class DocumentServiceImpl implements DocumentService, DbKeys {
* @param connection {@link DynamoDbConnectionBuilder}
* @param documentsTable {@link String}
* @param documentVersionsService {@link DocumentVersionService}
* @param documentEventService {@link EventService}
*/
public DocumentServiceImpl(final DynamoDbConnectionBuilder connection,
final String documentsTable, final DocumentVersionService documentVersionsService,
final EventService documentEventService) {
final String documentsTable, final DocumentVersionService documentVersionsService) {

if (documentsTable == null) {
throw new IllegalArgumentException("'documentsTable' is null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public void before() throws Exception {
this.df.setTimeZone(TimeZone.getTimeZone("UTC"));
DynamoDbConnectionBuilder dynamoDbConnection = DynamoDbTestServices.getDynamoDbConnection();
this.service = new DocumentServiceImpl(dynamoDbConnection, DOCUMENTS_TABLE,
new DocumentVersionServiceNoVersioning(), null);
this.searchService = new DocumentSearchServiceImpl(dynamoDbConnection, this.service,
DOCUMENTS_TABLE, null, null);
new DocumentVersionServiceNoVersioning());
this.searchService =
new DocumentSearchServiceImpl(dynamoDbConnection, this.service, DOCUMENTS_TABLE, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ public static void beforeAll() throws Exception {

DynamoDbConnectionBuilder dynamoDbConnection = DynamoDbTestServices.getDynamoDbConnection();
service = new DocumentServiceImpl(dynamoDbConnection, DOCUMENTS_TABLE,
new DocumentVersionServiceNoVersioning(), null);
new DocumentVersionServiceNoVersioning());
searchService =
new DocumentSearchServiceImpl(dynamoDbConnection, service, DOCUMENTS_TABLE, null, null);
new DocumentSearchServiceImpl(dynamoDbConnection, service, DOCUMENTS_TABLE, null);
}

/** {@link SimpleDateFormat}. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import static com.formkiq.testutils.aws.TestServices.createSnsTopic;
import static com.formkiq.testutils.aws.TestServices.createSqsSubscriptionToSnsTopic;
import static com.formkiq.testutils.aws.TestServices.getMessagesFromSqs;
import static com.formkiq.testutils.aws.TestServices.getSnsConnection;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
Expand Down Expand Up @@ -60,8 +59,6 @@
import com.formkiq.aws.dynamodb.model.DynamicDocumentItem;
import com.formkiq.aws.dynamodb.model.SearchMetaCriteria;
import com.formkiq.aws.dynamodb.model.SearchQuery;
import com.formkiq.module.events.EventService;
import com.formkiq.module.events.EventServiceSns;
import com.formkiq.testutils.aws.DynamoDbExtension;
import com.formkiq.testutils.aws.DynamoDbTestServices;
import com.formkiq.testutils.aws.LocalStackExtension;
Expand Down Expand Up @@ -94,14 +91,13 @@ static void beforeAll() throws Exception {
String snsTopicArn = createSnsTopic();
sqsQueueUrl = createSqsSubscriptionToSnsTopic(snsTopicArn);

EventService eventService = new EventServiceSns(getSnsConnection(null), snsTopicArn);
DynamoDbConnectionBuilder dynamoDbConnection = DynamoDbTestServices.getDynamoDbConnection();
index = new FolderIndexProcessorImpl(dynamoDbConnection, DOCUMENTS_TABLE);

service = new DocumentServiceImpl(dynamoDbConnection, DOCUMENTS_TABLE,
new DocumentVersionServiceNoVersioning(), null);
searchService = new DocumentSearchServiceImpl(dynamoDbConnection, service, DOCUMENTS_TABLE,
null, eventService);
new DocumentVersionServiceNoVersioning());
searchService =
new DocumentSearchServiceImpl(dynamoDbConnection, service, DOCUMENTS_TABLE, null);
dbService = new DynamoDbServiceImpl(dynamoDbConnection, DOCUMENTS_TABLE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
import com.formkiq.client.invoker.ApiException;
import com.formkiq.client.invoker.Configuration;
import com.formkiq.client.model.DeleteIndicesResponse;
import com.formkiq.module.events.EventService;
import com.formkiq.module.events.EventServiceSns;
import com.formkiq.stacks.api.handler.FormKiQResponseCallback;
import com.formkiq.stacks.dynamodb.DocumentItemDynamoDb;
import com.formkiq.stacks.dynamodb.DocumentSearchService;
Expand All @@ -63,7 +61,6 @@
import com.formkiq.testutils.aws.FormKiqApiExtension;
import com.formkiq.testutils.aws.JwtTokenEncoder;
import com.formkiq.testutils.aws.LocalStackExtension;
import com.formkiq.testutils.aws.TestServices;

/** Unit Tests for request /indices/{type}/{key}. */
@ExtendWith(LocalStackExtension.class)
Expand Down Expand Up @@ -92,12 +89,9 @@ public class IndicesRequestHandlerTest {
@BeforeAll
public static void beforeAll() throws URISyntaxException {
DynamoDbConnectionBuilder db = DynamoDbTestServices.getDynamoDbConnection();
EventService documentEventService =
new EventServiceSns(TestServices.getSnsConnection(null), null);
documentService = new DocumentServiceImpl(db, DOCUMENTS_TABLE,
new DocumentVersionServiceNoVersioning(), documentEventService);
dss = new DocumentSearchServiceImpl(db, documentService, DOCUMENTS_TABLE, null,
documentEventService);
documentService =
new DocumentServiceImpl(db, DOCUMENTS_TABLE, new DocumentVersionServiceNoVersioning());
dss = new DocumentSearchServiceImpl(db, documentService, DOCUMENTS_TABLE, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
import com.formkiq.aws.ssm.SsmConnectionBuilder;
import com.formkiq.aws.ssm.SsmService;
import com.formkiq.aws.ssm.SsmServiceImpl;
import com.formkiq.module.events.EventService;
import com.formkiq.module.events.EventServiceSns;
import com.formkiq.stacks.dynamodb.DocumentSearchService;
import com.formkiq.stacks.dynamodb.DocumentSearchServiceImpl;
import com.formkiq.stacks.dynamodb.DocumentService;
Expand Down Expand Up @@ -136,12 +134,10 @@ public static void beforeClass() throws IOException {

dbConnection =
new DynamoDbConnectionBuilder(false).setCredentials(awsprofile).setRegion(awsregion);
EventService eventService = new EventServiceSns(snsBuilder, snsDocumentEventArn);
documentService = new DocumentServiceImpl(dbConnection, documentsTable,
new DocumentVersionServiceNoVersioning(), eventService);
EventService documentEventService = eventService;
searchService = new DocumentSearchServiceImpl(dbConnection, documentService, documentsTable,
null, documentEventService);
new DocumentVersionServiceNoVersioning());
searchService =
new DocumentSearchServiceImpl(dbConnection, documentService, documentsTable, null);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
import com.formkiq.module.actions.ActionType;
import com.formkiq.module.actions.services.ActionsService;
import com.formkiq.module.actions.services.ActionsServiceDynamoDb;
import com.formkiq.module.events.EventService;
import com.formkiq.module.events.EventServiceSns;
import com.formkiq.module.typesense.TypeSenseService;
import com.formkiq.module.typesense.TypeSenseServiceImpl;
import com.formkiq.stacks.dynamodb.ConfigService;
Expand Down Expand Up @@ -156,11 +154,8 @@ public static void beforeClass() throws Exception {
dbBuilder = DynamoDbTestServices.getDynamoDbConnection();

DocumentVersionService versionService = new DocumentVersionServiceNoVersioning();
EventService documentEventService =
new EventServiceSns(TestServices.getSnsConnection(null), null);

documentService =
new DocumentServiceImpl(dbBuilder, DOCUMENTS_TABLE, versionService, documentEventService);
documentService = new DocumentServiceImpl(dbBuilder, DOCUMENTS_TABLE, versionService);
actionsService = new ActionsServiceDynamoDb(dbBuilder, DOCUMENTS_TABLE);
createMockServer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
import com.formkiq.module.actions.ActionType;
import com.formkiq.module.actions.services.ActionsService;
import com.formkiq.module.actions.services.ActionsServiceDynamoDb;
import com.formkiq.module.events.EventService;
import com.formkiq.module.events.EventServiceSns;
import com.formkiq.stacks.dynamodb.DocumentService;
import com.formkiq.stacks.dynamodb.DocumentServiceImpl;
import com.formkiq.stacks.dynamodb.DocumentVersionServiceNoVersioning;
Expand Down Expand Up @@ -216,9 +214,8 @@ public static void beforeClass() throws URISyntaxException, InterruptedException
dbHelper.createCacheTable(CACHE_TABLE);
}

EventService documentEventService = new EventServiceSns(snsBuilder, snsDocumentEvent);
service = new DocumentServiceImpl(dbBuilder, DOCUMENTS_TABLE,
new DocumentVersionServiceNoVersioning(), documentEventService);
new DocumentVersionServiceNoVersioning());
actionsService = new ActionsServiceDynamoDb(dbBuilder, DOCUMENTS_TABLE);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@
import com.formkiq.module.actions.ActionType;
import com.formkiq.module.actions.services.ActionsService;
import com.formkiq.module.actions.services.ActionsServiceDynamoDb;
import com.formkiq.module.events.EventService;
import com.formkiq.module.events.EventServiceSns;
import com.formkiq.module.events.document.DocumentEvent;
import com.formkiq.stacks.dynamodb.DocumentItemDynamoDb;
import com.formkiq.stacks.dynamodb.DocumentService;
Expand Down Expand Up @@ -251,9 +249,8 @@ public static void beforeClass() throws URISyntaxException, InterruptedException
String sqsQueueArn = sqsService.getQueueArn(sqsDocumentEventUrl);
snsService.subscribe(snsDocumentEvent, "sqs", sqsQueueArn);

EventService documentEventService = new EventServiceSns(snsBuilder, snsDocumentEvent);
service = new DocumentServiceImpl(dbBuilder, DOCUMENTS_TABLE,
new DocumentVersionServiceNoVersioning(), documentEventService);
new DocumentVersionServiceNoVersioning());

folderIndexProcesor = new FolderIndexProcessorImpl(dbBuilder, DOCUMENTS_TABLE);

Expand Down

0 comments on commit 1f88cd5

Please sign in to comment.