Skip to content

Commit 840a062

Browse files
committed
Merge branch 'issue/CDM-22' into issue/CDM-23
2 parents ffe4f1f + 1c00c27 commit 840a062

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

.github/workflows/docker-publish.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
name: Build and publish to docker repo
22

3-
on:
4-
workflow_dispatch:
5-
push:
6-
branches:
7-
- main
8-
paths:
9-
- 'src/**'
10-
- 'pom.xml'
11-
- 'Dockerfile'
12-
- 'LICENSE.md'
13-
tags:
14-
- '*.*.*'
15-
- '*.*.*-*'
3+
on: workflow_dispatch
164

175
jobs:
186
build_and_publish:
@@ -50,4 +38,4 @@ jobs:
5038
context: .
5139
push: true
5240
tags: ${{ steps.meta.outputs.tags }}
53-
platforms: linux/amd64
41+
platforms: linux/amd64

src/main/java/datastax/astra/migrate/cql/CqlHelper.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public boolean initialize() {
6666
for (Featureset f : Featureset.values()) {
6767
if (f.toString().startsWith("TEST_")) continue; // Skip test features
6868
Feature feature = getFeature(f);
69-
if (null!=feature && feature.isEnabled())
69+
if (isFeatureEnabled(f))
7070
feature.alterProperties(this.propertyHelper);
7171
}
7272

@@ -211,14 +211,14 @@ private String cqlTargetInsert() {
211211
}
212212
}
213213

214-
if (featureMap.get(Featureset.CONSTANT_COLUMNS).isEnabled()) {
214+
if (isFeatureEnabled(Featureset.CONSTANT_COLUMNS)) {
215215
insertBinds += "," + featureMap.get(Featureset.CONSTANT_COLUMNS).getAsString(ConstantColumns.Property.COLUMN_VALUES);
216216
}
217217

218218
targetInsertQuery = "INSERT INTO " +
219219
getTargetKeyspaceTable() +
220220
" (" + propertyHelper.getAsString(KnownProperties.TARGET_COLUMN_NAMES) +
221-
((featureMap.get(Featureset.CONSTANT_COLUMNS).isEnabled()) ? "," + featureMap.get(Featureset.CONSTANT_COLUMNS).getAsString(ConstantColumns.Property.COLUMN_NAMES) : "") +
221+
(isFeatureEnabled(Featureset.CONSTANT_COLUMNS) ? "," + featureMap.get(Featureset.CONSTANT_COLUMNS).getAsString(ConstantColumns.Property.COLUMN_NAMES) : "") +
222222
") VALUES (" + insertBinds + ")";
223223
if (null != getTtlCols() && !getTtlCols().isEmpty()) {
224224
targetInsertQuery += " USING TTL ?";
@@ -536,4 +536,11 @@ private boolean isTargetPrimaryKeyColumn(String colName) {
536536
public Feature getFeature(Featureset featureEnum) {
537537
return featureMap.get(featureEnum);
538538
}
539+
540+
public Boolean isFeatureEnabled(Featureset featureEnum) {
541+
if (!featureMap.containsKey(featureEnum)) {
542+
return false;
543+
}
544+
return featureMap.get(featureEnum).isEnabled();
545+
}
539546
}

src/test/java/datastax/astra/migrate/CqlHelperTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
package datastax.astra.migrate;
22

33
import datastax.astra.migrate.cql.CqlHelper;
4+
import datastax.astra.migrate.cql.features.Featureset;
45
import datastax.astra.migrate.properties.KnownProperties;
56
import datastax.astra.migrate.properties.PropertyHelper;
67
import org.apache.spark.SparkConf;
78
import org.junit.jupiter.api.AfterEach;
89
import org.junit.jupiter.api.BeforeEach;
910
import org.junit.jupiter.api.Test;
1011

11-
import static org.junit.jupiter.api.Assertions.assertAll;
12-
import static org.junit.jupiter.api.Assertions.assertEquals;
12+
import static org.junit.jupiter.api.Assertions.*;
1313

1414
public class CqlHelperTest {
1515

@@ -54,4 +54,10 @@ public void smokeTest() {
5454
);
5555
}
5656

57+
@Test
58+
public void featureHelper_disabledWhenNull() {
59+
propertyHelper.initializeSparkConf(sparkConf);
60+
cqlHelper.initialize();
61+
assertFalse(cqlHelper.isFeatureEnabled(Featureset.TEST_UNIMPLEMENTED_FEATURE));
62+
}
5763
}

0 commit comments

Comments
 (0)