BUG-6647 Increase code coverage and clean up I
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / ServerSessionMock.java
index b50bb434828a7be50ea6b56f8f4be55d7f948e18..7f7a6455b30d502c0e5b5c3e624a1649edfa81b5 100644 (file)
@@ -9,31 +9,34 @@ package org.opendaylight.protocol.pcep.impl;
 
 import static org.mockito.Mockito.mock;
 import io.netty.channel.Channel;
-import io.netty.util.HashedWheelTimer;
+import io.netty.util.concurrent.Future;
+import io.netty.util.concurrent.GlobalEventExecutor;
 
 import org.opendaylight.protocol.pcep.PCEPCloseTermination;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
-import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
-import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.protocol.pcep.TerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder;
 
 public class ServerSessionMock extends PCEPSessionImpl {
 
-       private final MockPCE client;
+    private final MockPCE client;
 
-       public ServerSessionMock(final PCEPSessionListener listener, final PCEPSessionListener client) {
-               super(new HashedWheelTimer(), listener, 5, mock(Channel.class), new PCEPOpenObject(4, 9, 2), new PCEPOpenObject(4, 9, 2));
-               this.client = (MockPCE) client;
-       }
+    public ServerSessionMock(final PCEPSessionListener listener, final PCEPSessionListener client) {
+        super(listener, 5, mock(Channel.class), new OpenBuilder().setKeepalive((short) 4).setDeadTimer((short) 9).setSessionId(
+                (short) 2).build(), new OpenBuilder().setKeepalive((short) 4).setDeadTimer((short) 9).setSessionId((short) 2).build());
+        this.client = (MockPCE) client;
+    }
 
-       @Override
-       public void sendMessage(final PCEPMessage msg) {
-               this.lastMessageSentAt = System.nanoTime();
-               this.client.onMessage(this, msg);
-       }
+    @Override
+    public Future<Void> sendMessage(final Message msg) {
+        this.lastMessageSentAt = System.nanoTime();
+        this.client.onMessage(this, msg);
+        return GlobalEventExecutor.INSTANCE.newSucceededFuture(null);
+    }
 
-       @Override
-       public void close() {
-               this.client.onSessionTerminated(this, new PCEPCloseTermination(Reason.UNKNOWN));
-       }
+    @Override
+    public void close() {
+        this.client.onSessionTerminated(this, new PCEPCloseTermination(TerminationReason.UNKNOWN));
+    }
 }