2 * Copyright (c) 2016 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
9 package org.opendaylight.protocol.bgp.parser.spi;
11 import java.util.Optional;
12 import org.junit.Assert;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.mockito.Mock;
16 import org.mockito.Mockito;
17 import org.mockito.MockitoAnnotations;
18 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.Ipv4AddressFamily;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.UnicastSubsequentAddressFamily;
23 public class MultiPathSupportUtilTest {
25 private static final BgpTableType AFI_SAFI = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
28 private PeerSpecificParserConstraint constraints;
31 private MultiPathSupport mpSupport;
35 MockitoAnnotations.initMocks(this);
39 public void testIsTableTypeSupportedPossitive() {
40 Mockito.doReturn(Optional.of(this.mpSupport)).when(this.constraints).getPeerConstraint(Mockito.any());
41 Mockito.doReturn(true).when(this.mpSupport).isTableTypeSupported(Mockito.any());
42 Assert.assertTrue(MultiPathSupportUtil.isTableTypeSupported(this.constraints, AFI_SAFI));
46 public void testIsTableTypeSupportedNegativeTableTypeNotSupported() {
47 Mockito.doReturn(Optional.of(this.mpSupport)).when(this.constraints).getPeerConstraint(Mockito.any());
48 Mockito.doReturn(false).when(this.mpSupport).isTableTypeSupported(Mockito.any());
49 Assert.assertFalse(MultiPathSupportUtil.isTableTypeSupported(this.constraints, AFI_SAFI));
53 public void testIsTableTypeSupportedNegativeMpSupportAbsent() {
54 Mockito.doReturn(Optional.empty()).when(this.constraints).getPeerConstraint(Mockito.any());
55 Assert.assertFalse(MultiPathSupportUtil.isTableTypeSupported(this.constraints, AFI_SAFI));
59 public void testIsTableTypeSupportedNegativeNull() {
60 Assert.assertFalse(MultiPathSupportUtil.isTableTypeSupported(null, AFI_SAFI));
63 @Test(expected=NullPointerException.class)
64 public void testIsTableTypeSupportedNPE() {
65 MultiPathSupportUtil.isTableTypeSupported(null, null);