Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 8ddb14d

Browse files
committed
#328 The default schema and triggers database names default to forests on one host
1 parent 31477e9 commit 8ddb14d

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

src/main/java/com/marklogic/appdeployer/DefaultAppConfigFactory.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,9 +669,30 @@ public AppConfig newAppConfig() {
669669
propertyConsumerMap.get(propertyName).accept(appConfig, value);
670670
}
671671
}
672+
673+
setDefaultsForDatabasesWithForestsOnOneHost(appConfig);
674+
672675
return appConfig;
673676
}
674677

678+
protected void setDefaultsForDatabasesWithForestsOnOneHost(AppConfig appConfig) {
679+
Set<String> set = appConfig.getDatabasesWithForestsOnOneHost();
680+
if (set == null || set.isEmpty()) {
681+
set = new HashSet<>();
682+
final String triggersName = appConfig.getTriggersDatabaseName();
683+
if (triggersName != null) {
684+
set.add(triggersName);
685+
}
686+
final String schemasName = appConfig.getSchemasDatabaseName();
687+
if (schemasName != null) {
688+
set.add(schemasName);
689+
}
690+
if (!set.isEmpty()) {
691+
appConfig.setDatabasesWithForestsOnOneHost(set);
692+
}
693+
}
694+
}
695+
675696
protected Map<String, String> buildMapFromCommaDelimitedString(String str) {
676697
Map<String, String> map = new HashMap<>();
677698
String[] tokens = str.split(",");

src/test/java/com/marklogic/appdeployer/DefaultAppConfigFactoryTest.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,4 +386,32 @@ public void mlUsernameAndPassword() {
386386
assertNull("SSL context should be null by default", config.getRestSslContext());
387387
assertNull("SSL hostname verifier should be null by default", config.getRestSslHostnameVerifier());
388388
}
389+
390+
@Test
391+
public void schemasAndTriggerDatabaseNamesShouldBeInSetOfDatabasesWithForestsOnOneHost() {
392+
sut = new DefaultAppConfigFactory(new SimplePropertySource("mlAppName", "example"));
393+
AppConfig config = sut.newAppConfig();
394+
assertEquals("example-triggers", config.getTriggersDatabaseName());
395+
assertEquals("example-schemas", config.getSchemasDatabaseName());
396+
397+
Set<String> set = config.getDatabasesWithForestsOnOneHost();
398+
assertTrue(set.contains("example-triggers"));
399+
assertTrue(set.contains("example-schemas"));
400+
}
401+
402+
@Test
403+
public void dontModifySetOfDatabasesWithForestsOnOneHostIfItsBeenConfigured() {
404+
sut = new DefaultAppConfigFactory(new SimplePropertySource("mlAppName", "example", "mlDatabasesWithForestsOnOneHost", "db1,db2"));
405+
AppConfig config = sut.newAppConfig();
406+
407+
Set<String> set = config.getDatabasesWithForestsOnOneHost();
408+
assertEquals(2, set.size());
409+
assertTrue(set.contains("db1"));
410+
assertTrue(set.contains("db2"));
411+
412+
final String message = "If the user has configured the set of databases, then the default schema and trigger databases names should not be added automatically";
413+
assertFalse(message, set.contains("example-triggers"));
414+
assertFalse(message, set.contains("example-schemas"));
415+
416+
}
389417
}

0 commit comments

Comments
 (0)