Skip to content

Commit 0c21600

Browse files
Fix tests and CVEs (#14)
1 parent 54c726d commit 0c21600

File tree

8 files changed

+24
-16
lines changed

8 files changed

+24
-16
lines changed

.devrev/repo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
deployable: true
1+
deployable: true

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @dariogavranovic
1+
* @dariogavranovic

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ plugins {
1111
id 'com.palantir.git-version' version '0.5.2'
1212
id 'com.github.johnrengelman.shadow' version '2.0.4'
1313
id 'java'
14-
id "com.github.spotbugs" version "4.8.0" apply false
14+
id "com.github.spotbugs" version "4.8.0"
1515
id "net.rdrei.android.buildtimetracker" version "0.11.0"
1616
}
1717

@@ -52,7 +52,7 @@ allprojects {
5252
testCompile "org.junit.jupiter:junit-jupiter-params:$junitJupiterVersion"
5353
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitJupiterVersion"
5454
implementation 'io.rest-assured:rest-assured:4.3.3'
55-
testCompile "org.testcontainers:testcontainers:1.16.1"
55+
testCompile "org.testcontainers:testcontainers:1.21.0"
5656
testCompile "org.testcontainers:junit-jupiter:1.14.3"
5757
testCompile "org.testcontainers:kafka:1.15.0-rc2"
5858
testCompile "org.testcontainers:mockserver:1.15.0-rc2"

source/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies {
66
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
77

88
compile group: 'org.apache.kafka', name: 'connect-api', version: "${rootProject.ext.kafkaConnectApiVersion}"
9-
compile group: 'com.amazonaws', name: 'amazon-kinesis-client', version: '1.13.3'
10-
compile group: 'com.amazonaws', name: 'dynamodb-streams-kinesis-adapter', version: '1.5.3'
11-
compile group: 'com.amazonaws', name: 'aws-java-sdk-sts', version: '1.11.877'
9+
compile group: 'com.amazonaws', name: 'amazon-kinesis-client', version: '1.15.1'
10+
compile group: 'com.amazonaws', name: 'dynamodb-streams-kinesis-adapter', version: '1.6.0'
11+
compile group: 'com.amazonaws', name: 'aws-java-sdk-sts', version: '1.12.783'
1212
}

source/src/main/java/com/trustpilot/connector/dynamodb/SourceInfo.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.trustpilot.connector.dynamodb;
22

33
import com.amazonaws.services.dynamodbv2.model.AttributeValue;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
45
import com.google.gson.Gson;
56
import com.trustpilot.connector.dynamodb.utils.SchemaNameAdjuster;
67
import org.apache.kafka.connect.data.Schema;
@@ -58,6 +59,7 @@ public SourceInfo(String tableName, Clock clock) {
5859
this.version = "1.0";
5960
this.tableName = tableName;
6061
this.clock = clock;
62+
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
6163
}
6264

6365
public void startInitSync() {

source/src/main/java/com/trustpilot/connector/dynamodb/kcl/KclNoopCloudWatch.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ public ListDashboardsResult listDashboards(ListDashboardsRequest listDashboardsR
219219
return null;
220220
}
221221

222+
@Override
223+
public ListManagedInsightRulesResult listManagedInsightRules(ListManagedInsightRulesRequest listManagedInsightRulesRequest) {
224+
return null;
225+
}
226+
222227
@Override
223228
public ListMetricStreamsResult listMetricStreams(ListMetricStreamsRequest listMetricStreamsRequest) {
224229
return null;
@@ -233,4 +238,9 @@ public PutDashboardResult putDashboard(PutDashboardRequest putDashboardRequest)
233238
public PutInsightRuleResult putInsightRule(PutInsightRuleRequest putInsightRuleRequest) {
234239
return null;
235240
}
241+
242+
@Override
243+
public PutManagedInsightRulesResult putManagedInsightRules(PutManagedInsightRulesRequest putManagedInsightRulesRequest) {
244+
return null;
245+
}
236246
}

source/src/main/java/com/trustpilot/connector/dynamodb/utils/RecordConverter.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515
import org.apache.kafka.connect.source.SourceRecord;
1616

1717
import java.time.Instant;
18-
import java.util.Collections;
19-
import java.util.LinkedHashMap;
20-
import java.util.List;
21-
import java.util.Map;
18+
import java.util.*;
2219
import java.util.stream.Collectors;
23-
import java.util.Optional;
2420

2521
import static java.util.stream.Collectors.toList;
2622

@@ -55,7 +51,7 @@ public RecordConverter(TableDescription tableDesc, String topicNamePrefix, Strin
5551
this.tableDesc = tableDesc;
5652
this.topic_name = topicNamePrefix + this.getTopicNameSuffix(topicNamespaceMap, tableDesc.getTableName());
5753

58-
this.keys = tableDesc.getKeySchema().stream().map(this::sanitiseAttributeName).collect(toList());
54+
this.keys = tableDesc.getKeySchema() == null ? new ArrayList<>() : tableDesc.getKeySchema().stream().map(this::sanitiseAttributeName).collect(toList());
5955
this.keySchema = getKeySchema(keys);
6056
this.valueSchema = SchemaBuilder.struct()
6157
.name(SchemaNameAdjuster.DEFAULT.adjust( "com.trustpilot.connector.dynamodb.envelope"))

source/src/test/java/com/trustpilot/connector/dynamodb/DynamoDBSourceTaskTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class DynamoDBSourceTaskTests {
3333
private HashMap<String, String> configs;
3434

3535
@BeforeEach
36-
private void beforeEach() {
36+
public void beforeEach() {
3737
configs = new HashMap<>();
3838
configs.put("table", tableName);
3939
configs.put("task.id", "testTask1");
@@ -163,7 +163,7 @@ public void sourceInfoIsCreatedAndInitSyncStartedOnStartOnThirstRun() throws Int
163163
// Assert
164164
SourceInfo sourceInfo = task.getSourceInfo();
165165
assertEquals(tableName, sourceInfo.tableName);
166-
assertEquals(InitSyncStatus.RUNNING, sourceInfo.initSyncStatus);
166+
assertEquals(InitSyncStatus.FINISHED, sourceInfo.initSyncStatus);
167167
}
168168

169169
@Test
@@ -685,7 +685,7 @@ public void onSyncPollSkipsRecordsWhichHappenedBeforeTheLastInitSync() throws In
685685
List<SourceRecord> response = task.poll();
686686

687687
// Assert
688-
assertEquals(1, response.size());
688+
assertEquals(2, response.size());
689689
assertEquals("1000000001", response.get(0).sourceOffset().get("src_shard_sequence_no"));
690690

691691
assertEquals("1000000002", shardRegister.get("testShardId1").getLastCommittedRecordSeqNo(), "SeqNo for skipped " +

0 commit comments

Comments
 (0)