Revert "BUG-47 : unfinished PCEP migration to generated DTOs."
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / ServerSessionMock.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.pcep.impl;
9
10 import static org.mockito.Mockito.mock;
11 import io.netty.channel.Channel;
12 import io.netty.util.HashedWheelTimer;
13
14 import org.opendaylight.protocol.pcep.PCEPCloseTermination;
15 import org.opendaylight.protocol.pcep.PCEPSessionListener;
16 import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
17 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
19
20 public class ServerSessionMock extends PCEPSessionImpl {
21
22         private final MockPCE client;
23
24         public ServerSessionMock(final PCEPSessionListener listener, final PCEPSessionListener client) {
25                 super(new HashedWheelTimer(), listener, 5, mock(Channel.class), new PCEPOpenObject(4, 9, 2), new PCEPOpenObject(4, 9, 2));
26                 this.client = (MockPCE) client;
27         }
28
29         @Override
30         public void sendMessage(final Message msg) {
31                 this.lastMessageSentAt = System.nanoTime();
32                 this.client.onMessage(this, msg);
33         }
34
35         @Override
36         public void close() {
37                 this.client.onSessionTerminated(this, new PCEPCloseTermination(Reason.UNKNOWN));
38         }
39 }