BUG-6647 Increase code coverage and clean up II
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / MockPCE.java
index 7d9278c03f89ae82b327b39681bcae913a595d0f..7c9ee85a238895364f6224b4aaeffa320a0927f5 100644 (file)
@@ -9,82 +9,47 @@ package org.opendaylight.protocol.pcep.impl;
 
 import java.util.ArrayList;
 import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.opendaylight.protocol.framework.TerminationReason;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
-import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
-import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
-import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
-
-/**
- *
- */
-public class MockPCE extends PCEPSessionListener {
-
-       private final List<PCEPMessage> listMsg = new ArrayList<PCEPMessage>();
-
-       private PCEPSessionImpl session = null;
-
-       public boolean up = false;
-
-       private static final Logger logger = LoggerFactory.getLogger(MockPCE.class);
+import org.opendaylight.protocol.pcep.PCEPTerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-       public boolean down = false;
+public class MockPCE implements PCEPSessionListener {
 
-       public MockPCE() {
-       }
+    private final List<Message> listMsg = new ArrayList<Message>();
 
-       public void sendMessage(PCEPMessage msg) {
-               this.session.handleMessage(msg);
-       }
+    private PCEPSessionImpl session = null;
 
-       public void sendErrorMessage(PCEPErrors value,
-                       PCEPOpenObject open) {
-               final PCEPErrorObject error = new PCEPErrorObject(value);
-               final List<PCEPErrorObject> errors = new ArrayList<PCEPErrorObject>();
-               errors.add(error);
-               this.sendMessage(new PCEPErrorMessage(open, errors, null));
-       }
+    public boolean up = false;
 
-       public List<PCEPMessage> getListMsg() {
-               return this.listMsg;
-       }
+    private static final Logger LOG = LoggerFactory.getLogger(MockPCE.class);
 
-       public void addSession(PCEPSessionImpl l) {
-               this.session = l;
-       }
+    public boolean down = false;
 
-       @Override
-       public void onMessage(PCEPSession session, PCEPMessage message) {
-               this.listMsg.add(message);
-               logger.debug("Message received:" + message);
-       }
+    @Override
+    public void onMessage(final PCEPSession session, final Message message) {
+        this.listMsg.add(message);
+        LOG.debug("Message received: {}", message);
+    }
 
-       @Override
-       public void onSessionUp(PCEPSession session, PCEPOpenObject local,
-                       PCEPOpenObject remote) {
-               logger.debug("Session Up");
-               this.up = true;
-               this.notifyAll();
-       }
+    @Override
+    public void onSessionUp(final PCEPSession session) {
+        LOG.debug("Session Up");
+        this.up = true;
+        this.notifyAll();
+    }
 
-       @Override
-       public void onSessionDown(PCEPSession session, PCEPCloseObject reason, Exception e) {
-               logger.debug("Session Down");
-               this.down = true;
-               //this.notifyAll();
-       }
+    @Override
+    public void onSessionDown(final PCEPSession session, final Exception e) {
+        LOG.debug("Session Down.", e);
+        this.down = true;
+        // this.notifyAll();
+    }
 
-       @Override
-       public void onSessionTerminated(PCEPSession session,
-                       TerminationReason cause) {
-               logger.debug("Session terminated. Cause : " + cause.toString());
-       }
+    @Override
+    public void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason cause) {
+        LOG.debug("Session terminated. Cause : {}", cause);
+    }
 }