Cleanup deprecation warnings in bgp/cli
[bgpcep.git] / bgp / cli / src / test / java / org / opendaylight / protocol / bgp / cli / utils / PeerGroupStateCliUtilsTest.java
1 /*
2  * Copyright (c) 2017 AT&T Intellectual Property. 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.cli.utils;
9
10 import static org.junit.Assert.assertEquals;
11
12 import com.google.common.io.Resources;
13 import java.io.ByteArrayOutputStream;
14 import java.io.IOException;
15 import java.io.PrintStream;
16 import java.nio.charset.StandardCharsets;
17 import java.util.Collections;
18 import org.junit.Test;
19 import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.peer.group.PeerGroupBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.PeerGroupStateAugmentationBuilder;
21 import org.opendaylight.yangtools.yang.common.Uint32;
22
23 public final class PeerGroupStateCliUtilsTest {
24
25     private static final String TEST_GROUP = "test-group";
26     private final ByteArrayOutputStream output = new ByteArrayOutputStream();
27     private final PrintStream stream = new PrintStream(this.output);
28
29     @Test
30     public void testEmptyPeerGroupStateCli() throws IOException {
31         final PeerGroupBuilder peerGroup = new PeerGroupBuilder().setPeerGroupName(TEST_GROUP);
32         PeerGroupStateCliUtils.displayPeerOperationalState(Collections.singletonList(peerGroup.build()), this.stream);
33
34         final String expected = Resources.toString(getClass().getClassLoader().getResource("empty-peer-group.txt"),
35             StandardCharsets.UTF_8);
36         assertEquals(expected, this.output.toString());
37     }
38
39     @Test
40     public void testPeerGroupStateCli() throws IOException {
41         PeerGroupStateCliUtils.displayPeerOperationalState(Collections.singletonList(new PeerGroupBuilder()
42             .setPeerGroupName(TEST_GROUP)
43             .setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group
44                 .StateBuilder()
45                     .addAugmentation(new PeerGroupStateAugmentationBuilder()
46                         .setTotalPrefixes(Uint32.ONE)
47                         .setTotalPaths(Uint32.TWO)
48                         .build())
49                     .build())
50             .build()), this.stream);
51
52         final String expected = Resources.toString(getClass().getClassLoader().getResource("peer-group.txt"),
53             StandardCharsets.UTF_8);
54         assertEquals(expected, this.output.toString());
55     }
56 }