Use java 11 (#1050)
This commit is contained in:
@ -24,12 +24,9 @@
|
||||
package com.iluwatar.leaderelection.bully;
|
||||
|
||||
import com.iluwatar.leaderelection.*;
|
||||
import com.iluwatar.leaderelection.ring.RingInstance;
|
||||
import com.iluwatar.leaderelection.ring.RingMessageManager;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
@ -43,8 +40,7 @@ public class BullyMessageManagerTest {
|
||||
@Test
|
||||
public void testSendHeartbeatMessage() {
|
||||
Instance instance1 = new BullyInstance(null, 1, 1);
|
||||
Map<Integer, Instance> instanceMap = new HashMap<>();
|
||||
instanceMap.put(1, instance1);
|
||||
Map<Integer, Instance> instanceMap = Map.of(1, instance1);
|
||||
MessageManager messageManager = new BullyMessageManager(instanceMap);
|
||||
assertTrue(messageManager.sendHeartbeatMessage(1));
|
||||
}
|
||||
@ -56,11 +52,7 @@ public class BullyMessageManagerTest {
|
||||
Instance instance2 = new BullyInstance(null, 1, 2);
|
||||
Instance instance3 = new BullyInstance(null, 1, 3);
|
||||
Instance instance4 = new BullyInstance(null, 1, 4);
|
||||
Map<Integer, Instance> instanceMap = new HashMap<>();
|
||||
instanceMap.put(1, instance1);
|
||||
instanceMap.put(2, instance2);
|
||||
instanceMap.put(3, instance3);
|
||||
instanceMap.put(4, instance4);
|
||||
Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3, 4, instance4);
|
||||
instance1.setAlive(false);
|
||||
MessageManager messageManager = new BullyMessageManager(instanceMap);
|
||||
boolean result = messageManager.sendElectionMessage(3, "3");
|
||||
@ -84,11 +76,7 @@ public class BullyMessageManagerTest {
|
||||
Instance instance2 = new BullyInstance(null, 1, 2);
|
||||
Instance instance3 = new BullyInstance(null, 1, 3);
|
||||
Instance instance4 = new BullyInstance(null, 1, 4);
|
||||
Map<Integer, Instance> instanceMap = new HashMap<>();
|
||||
instanceMap.put(1, instance1);
|
||||
instanceMap.put(2, instance2);
|
||||
instanceMap.put(3, instance3);
|
||||
instanceMap.put(4, instance4);
|
||||
Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3, 4, instance4);
|
||||
instance1.setAlive(false);
|
||||
MessageManager messageManager = new BullyMessageManager(instanceMap);
|
||||
boolean result = messageManager.sendElectionMessage(2, "2");
|
||||
@ -102,11 +90,7 @@ public class BullyMessageManagerTest {
|
||||
Instance instance2 = new BullyInstance(null, 1, 2);
|
||||
Instance instance3 = new BullyInstance(null, 1, 3);
|
||||
Instance instance4 = new BullyInstance(null, 1, 4);
|
||||
Map<Integer, Instance> instanceMap = new HashMap<>();
|
||||
instanceMap.put(1, instance1);
|
||||
instanceMap.put(2, instance2);
|
||||
instanceMap.put(3, instance3);
|
||||
instanceMap.put(4, instance4);
|
||||
Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3, 4, instance4);
|
||||
instance1.setAlive(false);
|
||||
MessageManager messageManager = new BullyMessageManager(instanceMap);
|
||||
messageManager.sendLeaderMessage(2, 2);
|
||||
@ -129,10 +113,7 @@ public class BullyMessageManagerTest {
|
||||
Instance instance1 = new BullyInstance(null, 1, 1);
|
||||
Instance instance2 = new BullyInstance(null, 1, 2);
|
||||
Instance instance3 = new BullyInstance(null, 1, 3);
|
||||
Map<Integer, Instance> instanceMap = new HashMap<>();
|
||||
instanceMap.put(1, instance1);
|
||||
instanceMap.put(2, instance2);
|
||||
instanceMap.put(3, instance3);
|
||||
Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3);
|
||||
MessageManager messageManager = new BullyMessageManager(instanceMap);
|
||||
messageManager.sendHeartbeatInvokeMessage(2);
|
||||
Message message = new Message(MessageType.HEARTBEAT_INVOKE, "");
|
||||
|
@ -27,7 +27,6 @@ import com.iluwatar.leaderelection.*;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
@ -41,8 +40,7 @@ public class RingMessageManagerTest {
|
||||
@Test
|
||||
public void testSendHeartbeatMessage() {
|
||||
Instance instance1 = new RingInstance(null, 1, 1);
|
||||
Map<Integer, Instance> instanceMap = new HashMap<>();
|
||||
instanceMap.put(1, instance1);
|
||||
Map<Integer, Instance> instanceMap = Map.of(1, instance1);
|
||||
MessageManager messageManager = new RingMessageManager(instanceMap);
|
||||
assertTrue(messageManager.sendHeartbeatMessage(1));
|
||||
}
|
||||
@ -53,10 +51,7 @@ public class RingMessageManagerTest {
|
||||
Instance instance1 = new RingInstance(null, 1, 1);
|
||||
Instance instance2 = new RingInstance(null, 1, 2);
|
||||
Instance instance3 = new RingInstance(null, 1, 3);
|
||||
Map<Integer, Instance> instanceMap = new HashMap<>();
|
||||
instanceMap.put(1, instance1);
|
||||
instanceMap.put(2, instance2);
|
||||
instanceMap.put(3, instance3);
|
||||
Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3);
|
||||
MessageManager messageManager = new RingMessageManager(instanceMap);
|
||||
String messageContent = "2";
|
||||
messageManager.sendElectionMessage(2, messageContent);
|
||||
@ -78,10 +73,7 @@ public class RingMessageManagerTest {
|
||||
Instance instance1 = new RingInstance(null, 1, 1);
|
||||
Instance instance2 = new RingInstance(null, 1, 2);
|
||||
Instance instance3 = new RingInstance(null, 1, 3);
|
||||
Map<Integer, Instance> instanceMap = new HashMap<>();
|
||||
instanceMap.put(1, instance1);
|
||||
instanceMap.put(2, instance2);
|
||||
instanceMap.put(3, instance3);
|
||||
Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3);
|
||||
MessageManager messageManager = new RingMessageManager(instanceMap);
|
||||
String messageContent = "3";
|
||||
messageManager.sendLeaderMessage(2, 3);
|
||||
@ -102,10 +94,7 @@ public class RingMessageManagerTest {
|
||||
Instance instance1 = new RingInstance(null, 1, 1);
|
||||
Instance instance2 = new RingInstance(null, 1, 2);
|
||||
Instance instance3 = new RingInstance(null, 1, 3);
|
||||
Map<Integer, Instance> instanceMap = new HashMap<>();
|
||||
instanceMap.put(1, instance1);
|
||||
instanceMap.put(2, instance2);
|
||||
instanceMap.put(3, instance3);
|
||||
Map<Integer, Instance> instanceMap = Map.of(1, instance1, 2, instance2, 3, instance3);
|
||||
MessageManager messageManager = new RingMessageManager(instanceMap);
|
||||
messageManager.sendHeartbeatInvokeMessage(2);
|
||||
Message ringMessage = new Message(MessageType.HEARTBEAT_INVOKE, "");
|
||||
|
Reference in New Issue
Block a user