Skip to content

Commit

Permalink
fix: pr comment
Browse files Browse the repository at this point in the history
  • Loading branch information
junfuchen99 committed Nov 28, 2023
1 parent 94a42a4 commit 0ac979e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/aws/greengrass/detector/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
import com.aws.greengrass.util.Coerce;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

Expand All @@ -33,7 +34,7 @@ public class Config {
private AtomicBoolean includeIPv4LoopbackAddrs = new AtomicBoolean(DEFAULT_INCLUDE_IPV4_LOOPBACK_ADDRESSES);
private AtomicBoolean includeIPv4LinkLocalAddrs = new AtomicBoolean(DEFAULT_INCLUDE_IPV4_LINK_LOCAL_ADDRESSES);
@Getter
private final List<String> excludedIPAddresses = new ArrayList<>();
private final Set<String> excludedIPAddresses = new HashSet<>();

/**
* Config constructor.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import org.mockito.Mockito;
import org.mockito.stubbing.Answer;

import java.util.Collections;
import java.util.Arrays;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand All @@ -39,8 +39,8 @@ public void GIVEN_config_topics_WHEN_initialize_THEN_configuration_created() {
Topic excludedIpTopic = Mockito.mock(Topic.class);
String mockIncludeIPv4LoopbackAddrsConfig = "true";
String mockIncludeIPv4LinkLocalAddrsConfig = "true";
String mockExcludeIPsConfig = String.format("[%s]", TestConstants.IP_1);
List<String> mockList = Collections.singletonList(TestConstants.IP_1);
String mockExcludeIPsConfig = String.format("[%s, %s]", TestConstants.IP_1, TestConstants.IP_2);
List<String> mockList = Arrays.asList(TestConstants.IP_1, TestConstants.IP_2);
int mockPortValue = 9000;

// stub subscribe() to call just the callback method without adding watcher
Expand All @@ -67,7 +67,8 @@ public void GIVEN_config_topics_WHEN_initialize_THEN_configuration_created() {
assertEquals(mockPortValue, config.getDefaultPort());
assertEquals(Coerce.toBoolean(mockIncludeIPv4LoopbackAddrsConfig), config.isIncludeIPv4LoopbackAddrs());
assertEquals(Coerce.toBoolean(mockIncludeIPv4LinkLocalAddrsConfig), config.isIncludeIPv4LinkLocalAddrs());
assertEquals(Coerce.toStringList(mockExcludeIPsConfig), config.getExcludedIPAddresses());
assertEquals(config.getExcludedIPAddresses().size(), Coerce.toStringList(mockExcludeIPsConfig).size());
assertTrue(config.getExcludedIPAddresses().containsAll(Coerce.toStringList(mockExcludeIPsConfig)));
}

@Test
Expand Down

0 comments on commit 0ac979e

Please sign in to comment.