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 java.lang.reflect.Constructor;
15 import java.lang.reflect.InvocationTargetException;
16 import org.junit.Test;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.PeerRole;
18 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
20 public class PeerRoleUtilTest {
21 @Test(expected = UnsupportedOperationException.class)
22 public void testPrivateConstructor() throws Throwable {
23 final Constructor<PeerRoleUtil> c = PeerRoleUtil.class.getDeclaredConstructor();
24 c.setAccessible(true);
27 } catch (final InvocationTargetException e) {
33 public void roleForChange() {
34 assertNull(PeerRoleUtil.roleForChange(Optional.fromNullable(null)));
35 assertEquals(PeerRole.Ebgp, PeerRoleUtil.roleForChange(Optional.of(new ImmutableLeafNodeBuilder<>()
36 .withNodeIdentifier(PeerRoleUtil.PEER_ROLE_NID).withValue("ebgp").build())));
40 public void roleForString() {
41 assertEquals("ebgp",PeerRoleUtil.roleForString(PeerRole.Ebgp));
42 assertEquals("ibgp",PeerRoleUtil.roleForString(PeerRole.Ibgp));
43 assertEquals("rr-client",PeerRoleUtil.roleForString(PeerRole.RrClient));
44 assertEquals("internal",PeerRoleUtil.roleForString(PeerRole.Internal));