Skip to content

Commit

Permalink
Connection DSL does not require store (finos#2528)
Browse files Browse the repository at this point in the history
* Connection DSL does not require store

* Update Mongodb test for DSL update
  • Loading branch information
haroonsherjan authored and AFine-gs committed Jan 9, 2024
1 parent ec678f5 commit 9c5a04e
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,14 @@ public MongoDBConnectionParseTreeWalker(ParseTreeWalkerSourceInformation walkerS
public void visitMongoDBConnectionValue(MongoDBConnectionParserGrammar.DefinitionContext ctx, MongoDBConnection connectionValue, boolean isEmbedded)
{
// store (optional if the store is provided by embedding context, if not provided, it is required)
MongoDBConnectionParserGrammar.ConnectionStoreContext connectionStoreContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.connectionStore(), "store", connectionValue.sourceInformation);
MongoDBConnectionParserGrammar.ConnectionStoreContext connectionStoreContext = PureGrammarParserUtility.validateAndExtractOptionalField(ctx.connectionStore(), "store", connectionValue.sourceInformation);
if (connectionStoreContext != null)
{
connectionValue.element = PureGrammarParserUtility.fromQualifiedName(connectionStoreContext.qualifiedName().packagePath() == null ? Collections.emptyList() : connectionStoreContext.qualifiedName().packagePath().identifier(), connectionStoreContext.qualifiedName().identifier());
connectionValue.elementSourceInformation = this.walkerSourceInformation.getSourceInformation(connectionStoreContext.qualifiedName());
connectionValue.type = DatabaseType.MongoDb;
}
else if (!isEmbedded)
{
// Copied from service store, do we need this??
PureGrammarParserUtility.validateAndExtractRequiredField(ctx.connectionStore(), "store", connectionValue.sourceInformation);
}
// database type
connectionValue.type = DatabaseType.MongoDb;
MongoDBDatasourceSpecification dsSpecification = getMongoDBDatasourceSpecification(ctx, connectionValue);
connectionValue.dataSourceSpecification = dsSpecification;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ protected String getDuplicatedElementTestCode()
"MongoDBConnection test::mongodb::connection" +
"{\n" +
" database: legend_db;\n" +
" store: mongo::test::db;\n" +
" serverURLs: [localhost:27071];\n" +
" authentication: # UserPassword {\n" +
" username: 'mongo_ro';\n" +
Expand All @@ -47,7 +46,7 @@ protected String getDuplicatedElementTestCode()
@Override
protected String getDuplicatedElementTestExpectedErrorMessage()
{
return "COMPILATION error at [16:1-18:1]: Duplicated element 'test::mongodb::connection'";
return "COMPILATION error at [15:1-17:1]: Duplicated element 'test::mongodb::connection'";
}

@Test
Expand All @@ -60,7 +59,6 @@ public void testMongoDBConnectionDefinitionv1()
"MongoDBConnection test::testConnection\n" +
"{\n" +
" database: legend_db;\n" +
" store: meta::external::store::mongodb::showcase::store::PersonDatabase;\n" +
" serverURLs: [localhost:27071];\n" +
" authentication: # UserPassword {\n" +
" username: 'mongo_ro';\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public String getParserGrammarIdentifierInclusionTestCode(List<String> keywords)
"MongoDBConnection " + ListAdapter.adapt(keywords).makeString("::") + "\n" +
"{\n" +
" database: legend_db;\n" +
" store: mongo::test::db;\n" +
" serverURLs: [localhost:27071];\n" +
" authentication: # UserPassword {\n" +
" username: 'mongo_ro';\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ public void visitRelationalDatabaseConnectionValue(RelationalDatabaseConnectionP
connectionValue.element = PureGrammarParserUtility.fromQualifiedName(storeContext.qualifiedName().packagePath() == null ? Collections.emptyList() : storeContext.qualifiedName().packagePath().identifier(), storeContext.qualifiedName().identifier());
connectionValue.elementSourceInformation = this.walkerSourceInformation.getSourceInformation(storeContext.qualifiedName());
}
else if (!isEmbedded)
{
// non-embedded connection requires store
PureGrammarParserUtility.validateAndExtractRequiredField(ctx.connectionStore(), "store", connectionValue.sourceInformation);
}
// database type
RelationalDatabaseConnectionParserGrammar.DbTypeContext dbTypeCtx = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.dbType(), "type", connectionValue.sourceInformation);
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,6 @@ public void testForMultipleRelationalConnections()
"###Connection\n" +
"RelationalDatabaseConnection relational::graphFetch::RelationalConnection\n" +
"{\n" +
" store: relational::graphFetch::dbInc;\n" +
" type: H2;\n" +
" specification: Static\n" +
" {\n" +
Expand Down Expand Up @@ -2225,7 +2224,7 @@ public void testForMultipleRelationalConnections()
" connection_1: relational::graphFetch::OneMappingConnection\n" +
" ]\n" +
" ];\n" +
"}\n", "COMPILATION error at [90:1-108:1]: Found 2 connections against store [dbInc] under a single runtime.");
"}\n", "COMPILATION error at [89:1-107:1]: Found 2 connections against store [dbInc] under a single runtime.");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testRelationalDatabaseConnection()
test("###Connection\n" +
"RelationalDatabaseConnection meta::mySimpleConnection\n" +
"{\n" +
"}\n\n", "PARSER error at [2:1-4:1]: Field 'store' is required");
"}\n\n", "PARSER error at [2:1-4:1]: Field 'type' is required");
test("###Connection\n" +
"RelationalDatabaseConnection meta::mySimpleConnection\n" +
"{\n" +
Expand Down

0 comments on commit 9c5a04e

Please sign in to comment.