c3b79bfac0c961e2a3050b8a5641939931df1e6f
[bgpcep.git] / bgp / rib-spi / src / test / java / org / opendaylight / protocol / bgp / rib / spi / PeerRoleUtilTest.java
1 /*
2  * Copyright (c) 2016 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.bgp.rib.spi;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNull;
12
13 import com.google.common.base.Optional;
14 import org.junit.Test;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
16 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
17
18 public class PeerRoleUtilTest {
19     @Test
20     public void roleForChange() {
21         assertNull(PeerRoleUtil.roleForChange(Optional.fromNullable(null)));
22         assertEquals(PeerRole.Ebgp, PeerRoleUtil.roleForChange(Optional.of(new ImmutableLeafNodeBuilder<>()
23                 .withNodeIdentifier(PeerRoleUtil.PEER_ROLE_NID).withValue("ebgp").build())));
24     }
25
26     @Test
27     public void roleForString() {
28         assertEquals("ebgp", PeerRoleUtil.roleForString(PeerRole.Ebgp));
29         assertEquals("ibgp", PeerRoleUtil.roleForString(PeerRole.Ibgp));
30         assertEquals("rr-client", PeerRoleUtil.roleForString(PeerRole.RrClient));
31         assertEquals("internal", PeerRoleUtil.roleForString(PeerRole.Internal));
32     }
33 }