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
8 package org.opendaylight.protocol.bgp.rib.spi;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNull;
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;
18 public class PeerRoleUtilTest {
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())));
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));