mirror of https://github.com/apache/kafka.git
MINOR: avoid double brace initialization (#19667)
Reviewers: Bill Bejeck <bill@confluent.io>
This commit is contained in:
parent
58c08441d1
commit
0b81d6c780
|
@ -62,7 +62,6 @@ import org.mockito.junit.jupiter.MockitoExtension;
|
|||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -96,12 +95,7 @@ import static org.mockito.Mockito.when;
|
|||
public class InternalTopicManagerTest {
|
||||
private final Node broker1 = new Node(0, "dummyHost-1", 1234);
|
||||
private final Node broker2 = new Node(1, "dummyHost-2", 1234);
|
||||
private final List<Node> cluster = new ArrayList<>(2) {
|
||||
{
|
||||
add(broker1);
|
||||
add(broker2);
|
||||
}
|
||||
};
|
||||
private final List<Node> cluster = List.of(broker1, broker2);
|
||||
private final String topic1 = "test_topic";
|
||||
private final String topic2 = "test_topic_2";
|
||||
private final String topic3 = "test_topic_3";
|
||||
|
@ -115,16 +109,14 @@ public class InternalTopicManagerTest {
|
|||
private InternalTopicManager internalTopicManager;
|
||||
private final MockTime time = new MockTime(0);
|
||||
|
||||
private final Map<String, Object> config = new HashMap<>() {
|
||||
{
|
||||
put(StreamsConfig.APPLICATION_ID_CONFIG, "app-id");
|
||||
put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, broker1.host() + ":" + broker1.port());
|
||||
put(StreamsConfig.REPLICATION_FACTOR_CONFIG, 1);
|
||||
put(StreamsConfig.producerPrefix(ProducerConfig.BATCH_SIZE_CONFIG), 16384);
|
||||
put(StreamsConfig.consumerPrefix(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG), 100);
|
||||
put(StreamsConfig.RETRY_BACKOFF_MS_CONFIG, 10);
|
||||
}
|
||||
};
|
||||
private final Map<String, Object> config = Map.of(
|
||||
StreamsConfig.APPLICATION_ID_CONFIG, "app-id",
|
||||
StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, broker1.host() + ":" + broker1.port(),
|
||||
StreamsConfig.REPLICATION_FACTOR_CONFIG, 1,
|
||||
StreamsConfig.producerPrefix(ProducerConfig.BATCH_SIZE_CONFIG), 16384,
|
||||
StreamsConfig.consumerPrefix(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG), 100,
|
||||
StreamsConfig.RETRY_BACKOFF_MS_CONFIG, 10
|
||||
);
|
||||
|
||||
@BeforeEach
|
||||
public void init() {
|
||||
|
@ -710,26 +702,38 @@ public class InternalTopicManagerTest {
|
|||
internalTopicManager.makeReady(Collections.singletonMap(topic4, topicConfig4));
|
||||
|
||||
assertEquals(Set.of(topic1, topic2, topic3, topic4), mockAdminClient.listTopics().names().get());
|
||||
assertEquals(new TopicDescription(topic1, false, new ArrayList<>() {
|
||||
{
|
||||
add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()));
|
||||
}
|
||||
}), mockAdminClient.describeTopics(Collections.singleton(topic1)).topicNameValues().get(topic1).get());
|
||||
assertEquals(new TopicDescription(topic2, false, new ArrayList<>() {
|
||||
{
|
||||
add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()));
|
||||
}
|
||||
}), mockAdminClient.describeTopics(Collections.singleton(topic2)).topicNameValues().get(topic2).get());
|
||||
assertEquals(new TopicDescription(topic3, false, new ArrayList<>() {
|
||||
{
|
||||
add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()));
|
||||
}
|
||||
}), mockAdminClient.describeTopics(Collections.singleton(topic3)).topicNameValues().get(topic3).get());
|
||||
assertEquals(new TopicDescription(topic4, false, new ArrayList<>() {
|
||||
{
|
||||
add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()));
|
||||
}
|
||||
}), mockAdminClient.describeTopics(Collections.singleton(topic4)).topicNameValues().get(topic4).get());
|
||||
assertEquals(
|
||||
new TopicDescription(
|
||||
topic1,
|
||||
false,
|
||||
List.of(new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()))
|
||||
),
|
||||
mockAdminClient.describeTopics(Collections.singleton(topic1)).topicNameValues().get(topic1).get()
|
||||
);
|
||||
assertEquals(
|
||||
new TopicDescription(
|
||||
topic2,
|
||||
false,
|
||||
List.of(new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()))
|
||||
),
|
||||
mockAdminClient.describeTopics(Collections.singleton(topic2)).topicNameValues().get(topic2).get()
|
||||
);
|
||||
assertEquals(
|
||||
new TopicDescription(
|
||||
topic3,
|
||||
false,
|
||||
List.of(new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()))
|
||||
),
|
||||
mockAdminClient.describeTopics(Collections.singleton(topic3)).topicNameValues().get(topic3).get()
|
||||
);
|
||||
assertEquals(
|
||||
new TopicDescription(
|
||||
topic4,
|
||||
false,
|
||||
List.of(new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList(), Collections.emptyList(), Collections.emptyList()))
|
||||
),
|
||||
mockAdminClient.describeTopics(Collections.singleton(topic4)).topicNameValues().get(topic4).get()
|
||||
);
|
||||
|
||||
final ConfigResource resource = new ConfigResource(ConfigResource.Type.TOPIC, topic1);
|
||||
final ConfigResource resource2 = new ConfigResource(ConfigResource.Type.TOPIC, topic2);
|
||||
|
@ -804,13 +808,12 @@ public class InternalTopicManagerTest {
|
|||
mockAdminClient.addTopic(
|
||||
false,
|
||||
topic1,
|
||||
new ArrayList<>() {
|
||||
{
|
||||
add(new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList()));
|
||||
add(new TopicPartitionInfo(1, broker1, singleReplica, Collections.emptyList()));
|
||||
}
|
||||
},
|
||||
null);
|
||||
List.of(
|
||||
new TopicPartitionInfo(0, broker1, singleReplica, Collections.emptyList()),
|
||||
new TopicPartitionInfo(1, broker1, singleReplica, Collections.emptyList())
|
||||
),
|
||||
null
|
||||
);
|
||||
|
||||
try {
|
||||
final InternalTopicConfig internalTopicConfig = new RepartitionTopicConfig(topic1, Collections.emptyMap());
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.junit.jupiter.api.Test;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
@ -41,32 +40,28 @@ import static org.mockito.Mockito.verify;
|
|||
|
||||
class ReadOnlyTaskTest {
|
||||
|
||||
private final List<String> readOnlyMethods = new LinkedList<>() {
|
||||
{
|
||||
add("needsInitializationOrRestoration");
|
||||
add("inputPartitions");
|
||||
add("changelogPartitions");
|
||||
add("commitRequested");
|
||||
add("commitNeeded");
|
||||
add("isActive");
|
||||
add("changelogOffsets");
|
||||
add("state");
|
||||
add("id");
|
||||
add("store");
|
||||
}
|
||||
};
|
||||
private final List<String> readOnlyMethods = List.of(
|
||||
"needsInitializationOrRestoration",
|
||||
"inputPartitions",
|
||||
"changelogPartitions",
|
||||
"commitRequested",
|
||||
"commitNeeded",
|
||||
"isActive",
|
||||
"changelogOffsets",
|
||||
"state",
|
||||
"id",
|
||||
"store"
|
||||
);
|
||||
|
||||
private final List<String> objectMethods = new LinkedList<>() {
|
||||
{
|
||||
add("wait");
|
||||
add("equals");
|
||||
add("getClass");
|
||||
add("hashCode");
|
||||
add("notify");
|
||||
add("notifyAll");
|
||||
add("toString");
|
||||
}
|
||||
};
|
||||
private final List<String> objectMethods = List.of(
|
||||
"wait",
|
||||
"equals",
|
||||
"getClass",
|
||||
"hashCode",
|
||||
"notify",
|
||||
"notifyAll",
|
||||
"toString"
|
||||
);
|
||||
|
||||
final Task task = statelessTask(new TaskId(1, 0)).build();
|
||||
|
||||
|
|
|
@ -58,11 +58,11 @@ import java.lang.reflect.Method;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.hasItem;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
@ -81,41 +81,39 @@ import static org.mockito.Mockito.mockingDetails;
|
|||
@MockitoSettings(strictness = Strictness.STRICT_STUBS)
|
||||
public class RocksDBGenericOptionsToDbOptionsColumnFamilyOptionsAdapterTest {
|
||||
|
||||
private final List<String> walRelatedMethods = new LinkedList<>() {
|
||||
{
|
||||
add("setManualWalFlush");
|
||||
add("setMaxTotalWalSize");
|
||||
add("setWalBytesPerSync");
|
||||
add("setWalDir");
|
||||
add("setWalFilter");
|
||||
add("setWalRecoveryMode");
|
||||
add("setWalSizeLimitMB");
|
||||
add("setWalTtlSeconds");
|
||||
}
|
||||
};
|
||||
private final List<String> walRelatedMethods = List.of(
|
||||
"setManualWalFlush",
|
||||
"setMaxTotalWalSize",
|
||||
"setWalBytesPerSync",
|
||||
"setWalDir",
|
||||
"setWalFilter",
|
||||
"setWalRecoveryMode",
|
||||
"setWalSizeLimitMB",
|
||||
"setWalTtlSeconds"
|
||||
);
|
||||
|
||||
private final List<String> ignoreMethods = new LinkedList<>() {
|
||||
{
|
||||
add("isOwningHandle");
|
||||
add("getNativeHandle");
|
||||
add("dispose");
|
||||
add("wait");
|
||||
add("equals");
|
||||
add("getClass");
|
||||
add("hashCode");
|
||||
add("notify");
|
||||
add("notifyAll");
|
||||
add("toString");
|
||||
add("getOptionStringFromProps");
|
||||
add("maxBackgroundCompactions");
|
||||
add("setMaxBackgroundCompactions");
|
||||
add("maxBackgroundFlushes");
|
||||
add("setMaxBackgroundFlushes");
|
||||
add("tablePropertiesCollectorFactory");
|
||||
add("setTablePropertiesCollectorFactory");
|
||||
addAll(walRelatedMethods);
|
||||
}
|
||||
};
|
||||
private final List<String> ignoreMethods = Stream.concat(
|
||||
Stream.of(
|
||||
"isOwningHandle",
|
||||
"getNativeHandle",
|
||||
"dispose",
|
||||
"wait",
|
||||
"equals",
|
||||
"getClass",
|
||||
"hashCode",
|
||||
"notify",
|
||||
"notifyAll",
|
||||
"toString",
|
||||
"getOptionStringFromProps",
|
||||
"maxBackgroundCompactions",
|
||||
"setMaxBackgroundCompactions",
|
||||
"maxBackgroundFlushes",
|
||||
"setMaxBackgroundFlushes",
|
||||
"tablePropertiesCollectorFactory",
|
||||
"setTablePropertiesCollectorFactory"
|
||||
),
|
||||
walRelatedMethods.stream()
|
||||
).collect(Collectors.toList());
|
||||
|
||||
@Test
|
||||
public void shouldOverwriteAllOptionsMethods() throws Exception {
|
||||
|
|
Loading…
Reference in New Issue