2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.bgp.parser.mock;
10 import java.util.List;
13 import org.opendaylight.protocol.framework.DeserializerException;
14 import org.opendaylight.protocol.framework.DocumentedException;
15 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
16 import org.opendaylight.yangtools.yang.binding.Notification;
19 * Mock implementation of {@link BGPMessageParser}. It implements the required interface by having two internal maps,
20 * each used in one of the methods. It looks up the key provided to the method and returns whatever value is stored in
23 public class BGPMessageParserMock implements ProtocolMessageFactory<Notification> {
24 private final Map<byte[], List<Notification>> messages;
27 * @param updateMessages Map<byte[], BGPUpdateEvent>
29 public BGPMessageParserMock(final Map<byte[], List<Notification>> messages) {
30 this.messages = messages;
34 public List<Notification> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
35 final List<Notification> ret = this.messages.get(bytes);
37 throw new IllegalArgumentException("Undefined message encountered");
43 public byte[] put(final Notification msg) {