Skip to content

Commit 9f95ea9

Browse files
committed
Added more UTs for coverage
1 parent 951e0db commit 9f95ea9

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

document-store/src/test/java/org/hypertrace/core/documentstore/model/config/TypesafeConfigDatastoreConfigExtractorTest.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,23 @@
44
import static org.hypertrace.core.documentstore.model.config.AggregatePipelineMode.SORT_OPTIMIZED_IF_POSSIBLE;
55
import static org.hypertrace.core.documentstore.model.options.DataFreshness.NEAR_REALTIME_FRESHNESS;
66
import static org.junit.jupiter.api.Assertions.assertEquals;
7+
import static org.junit.jupiter.api.Assertions.assertFalse;
78
import static org.junit.jupiter.api.Assertions.assertThrows;
9+
import static org.junit.jupiter.api.Assertions.assertTrue;
810

911
import com.typesafe.config.Config;
1012
import com.typesafe.config.ConfigFactory;
1113
import java.time.Duration;
1214
import java.util.List;
1315
import java.util.Map;
16+
import org.hypertrace.core.documentstore.model.config.postgres.PostgresConnectionConfig;
1417
import org.hypertrace.core.documentstore.model.options.DataFreshness;
1518
import org.junit.jupiter.api.Test;
1619
import org.junit.jupiter.params.ParameterizedTest;
1720
import org.junit.jupiter.params.provider.EnumSource;
1821

1922
class TypesafeConfigDatastoreConfigExtractorTest {
23+
2024
private static final String TYPE_KEY = "database_type";
2125
private static final String HOST_KEY = "hostname";
2226
private static final String PORT_KEY = "port_number";
@@ -387,6 +391,21 @@ void testBuildPostgresWithCollectionConfigs() {
387391
assertEquals(false, nonExistentConfig.isPresent());
388392
}
389393

394+
@Test
395+
void testBuildPostgresWithCollectionConfigWithoutTimestampFields() {
396+
final ConnectionConfig config =
397+
TypesafeConfigDatastoreConfigExtractor.from(
398+
buildConfigMapWithCollectionConfigWithoutTimestampFields(), TYPE_KEY)
399+
.extract()
400+
.connectionConfig();
401+
402+
final PostgresConnectionConfig postgresConfig = (PostgresConnectionConfig) config;
403+
404+
var collectionWithoutTs = postgresConfig.getCollectionConfig("collection_without_ts");
405+
assertTrue(collectionWithoutTs.isPresent());
406+
assertFalse(collectionWithoutTs.get().getTimestampFields().isPresent());
407+
}
408+
390409
private Config buildConfigMap() {
391410
return ConfigFactory.parseMap(
392411
Map.ofEntries(
@@ -516,4 +535,21 @@ private Config buildConfigMapWithCollectionConfigsForPostgres() {
516535
"postgres.collectionConfigs.entities_domain.timestampFields.lastUpdated",
517536
"update_ts")));
518537
}
538+
539+
private Config buildConfigMapWithCollectionConfigWithoutTimestampFields() {
540+
return ConfigFactory.parseMap(
541+
Map.ofEntries(
542+
entry(TYPE_KEY, "postgres"),
543+
entry("postgres.host", host),
544+
entry("postgres.port", port),
545+
entry("postgres.database", database),
546+
entry("postgres.user", user),
547+
entry("postgres.password", password),
548+
entry("appName", appName),
549+
entry("maxPoolSize", maxConnections),
550+
entry("connectionAccessTimeout", accessTimeout),
551+
entry("connectionIdleTime", surrenderTimeout),
552+
// Collection config exists but has no timestampFields - uses a dummy key
553+
entry("postgres.collectionConfigs.collection_without_ts.someOtherConfig", "value")));
554+
}
519555
}

0 commit comments

Comments
 (0)