Skip to content

Commit caa75c0

Browse files
committed
Avoid request building code duplication in BatchE2ET.java.
1 parent 4e84632 commit caa75c0

File tree

1 file changed

+9
-15
lines changed
  • powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools

1 file changed

+9
-15
lines changed

powertools-e2e-tests/src/test/java/software/amazon/lambda/powertools/BatchE2ET.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,16 @@ void sqsBatchProcessingSucceeds() {
171171
.build());
172172

173173
// THEN
174-
// When the retry loop finishes it means we found all products in the result
174+
ScanRequest scanRequest = ScanRequest.builder().tableName(outputTable).build();
175175
RetryUtils.withRetry(() -> {
176-
ScanResponse items = ddbClient.scan(ScanRequest.builder()
177-
.tableName(outputTable)
178-
.build());
176+
ScanResponse items = ddbClient.scan(scanRequest);
179177
if (!areAllTestProductsPresent(items)) {
180178
throw new DataNotReadyException("sqs-batch-processing not complete yet");
181179
}
182180
return null;
183181
}, "sqs-batch-processing", DataNotReadyException.class).get();
184182

185-
ScanResponse finalItems = ddbClient.scan(ScanRequest.builder().tableName(outputTable).build());
183+
ScanResponse finalItems = ddbClient.scan(scanRequest);
186184
assertThat(areAllTestProductsPresent(finalItems)).isTrue();
187185
}
188186

@@ -208,18 +206,16 @@ void kinesisBatchProcessingSucceeds() {
208206
.build());
209207

210208
// THEN
211-
// When the retry loop finishes it means we found all products in the result
209+
ScanRequest scanRequest = ScanRequest.builder().tableName(outputTable).build();
212210
RetryUtils.withRetry(() -> {
213-
ScanResponse items = ddbClient.scan(ScanRequest.builder()
214-
.tableName(outputTable)
215-
.build());
211+
ScanResponse items = ddbClient.scan(scanRequest);
216212
if (!areAllTestProductsPresent(items)) {
217213
throw new DataNotReadyException("kinesis-batch-processing not complete yet");
218214
}
219215
return null;
220216
}, "kinesis-batch-processing", DataNotReadyException.class).get();
221217

222-
ScanResponse finalItems = ddbClient.scan(ScanRequest.builder().tableName(outputTable).build());
218+
ScanResponse finalItems = ddbClient.scan(scanRequest);
223219
assertThat(areAllTestProductsPresent(finalItems)).isTrue();
224220
}
225221

@@ -241,18 +237,16 @@ void ddbStreamsBatchProcessingSucceeds() {
241237
.build());
242238

243239
// THEN
240+
ScanRequest scanRequest = ScanRequest.builder().tableName(outputTable).build();
244241
RetryUtils.withRetry(() -> {
245-
ScanResponse items = ddbClient.scan(ScanRequest.builder()
246-
.tableName(outputTable)
247-
.build());
248-
242+
ScanResponse items = ddbClient.scan(scanRequest);
249243
if (items.count() != 1) {
250244
throw new DataNotReadyException("DDB streams processing not complete yet");
251245
}
252246
return null;
253247
}, "ddb-streams-batch-processing", DataNotReadyException.class).get();
254248

255-
ScanResponse finalItems = ddbClient.scan(ScanRequest.builder().tableName(outputTable).build());
249+
ScanResponse finalItems = ddbClient.scan(scanRequest);
256250
assertThat(finalItems.count()).isEqualTo(1);
257251
assertThat(finalItems.items().get(0).get("id").s()).isEqualTo(theId);
258252
}

0 commit comments

Comments
 (0)