From acc9ab7a46147834e72b88a99da0307362f3b954 Mon Sep 17 00:00:00 2001 From: Evaldas Buinauskas <7301441+buinauskas@users.noreply.github.com> Date: Thu, 5 Oct 2023 09:39:26 +0300 Subject: [PATCH] Add retry strategy tests (#14) --- .../connect/vespa/VespaSinkConfigTest.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/test/java/com/vinted/kafka/connect/vespa/VespaSinkConfigTest.java diff --git a/src/test/java/com/vinted/kafka/connect/vespa/VespaSinkConfigTest.java b/src/test/java/com/vinted/kafka/connect/vespa/VespaSinkConfigTest.java new file mode 100644 index 0000000..2826c90 --- /dev/null +++ b/src/test/java/com/vinted/kafka/connect/vespa/VespaSinkConfigTest.java @@ -0,0 +1,34 @@ +package com.vinted.kafka.connect.vespa; + +import ai.vespa.feed.client.FeedClient; +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertIterableEquals; + +public class VespaSinkConfigTest { + private final Map params = new HashMap<>(); + + @Test + void createsDefaultRetryStrategy() { + VespaSinkConfig config = new VespaSinkConfig(params); + + assertEquals(10, config.retryStrategyRetries); + assertIterableEquals(Arrays.asList(FeedClient.OperationType.PUT, FeedClient.OperationType.UPDATE, FeedClient.OperationType.REMOVE), config.retryStrategyOperationsTypes); + } + + @Test + void overridesRetryStrategy() { + params.put("vespa.retry.strategy.retries", "20"); + params.put("vespa.retry.strategy.operation.types", "UPDATE,REMOVE"); + + VespaSinkConfig config = new VespaSinkConfig(params); + + assertEquals(20, config.retryStrategyRetries); + assertIterableEquals(Arrays.asList(FeedClient.OperationType.UPDATE, FeedClient.OperationType.REMOVE), config.retryStrategyOperationsTypes); + } +}