Improve the code coverage
[vfc/nfvo/driver/vnfm/svnfm.git] / huawei / vnfmadapter / VnfmadapterService / service / src / test / java / org / onap / vfc / nfvo / vnfm / svnfm / vnfmadapter / common / restclient / ReaderHelperTest.java
1 /*
2  * Copyright 2017 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
18
19 import static org.junit.Assert.assertEquals;
20
21 import java.io.Reader;
22 import java.io.StringReader;
23
24 import org.junit.After;
25 import org.junit.AfterClass;
26 import org.junit.Before;
27 import org.junit.BeforeClass;
28 import org.junit.Test;
29
30 /**
31  * <br/>
32  * <p>
33  * </p>
34  * 
35  * @author
36  * @version
37  */
38 public class ReaderHelperTest {
39
40     /**
41      * <br/>
42      * 
43      * @throws java.lang.Exception
44      * @since
45      */
46     @BeforeClass
47     public static void setUpBeforeClass() throws Exception {
48     }
49
50     /**
51      * <br/>
52      * 
53      * @throws java.lang.Exception
54      * @since
55      */
56     @AfterClass
57     public static void tearDownAfterClass() throws Exception {
58     }
59
60     /**
61      * <br/>
62      * 
63      * @throws java.lang.Exception
64      * @since
65      */
66     @Before
67     public void setUp() throws Exception {
68     }
69
70     /**
71      * <br/>
72      * 
73      * @throws java.lang.Exception
74      * @since
75      */
76     @After
77     public void tearDown() throws Exception {
78     }
79
80     /**
81      * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
82      */
83     @Test
84     public void testGetLine() {
85         final String message = "hello.. how are you?";
86         final Reader reader = new StringReader(message);
87         final ReaderHelper helper = new ReaderHelper(reader);
88         final String actual = helper.getLine();
89         assertEquals(message, actual);
90     }
91
92     /**
93      * Test method for {@link org.openo.baseservice.util.inf.ReaderHelper#getLine()}.
94      */
95     @Test
96     public void testGetLineMultiLine() {
97         final String line1 = "hello.. how are you?";
98         final String line2 = "I am fine.";
99         final Reader reader = new StringReader(line1 + System.lineSeparator() + line2);
100         final ReaderHelper helper = new ReaderHelper(reader);
101         String actual = helper.getLine();
102         assertEquals(line1, actual);
103         actual = helper.getLine();
104         assertEquals(line2, actual);
105         actual = helper.getLine();
106         assertEquals(null, actual);
107     }
108
109     @Test
110     public void testGetLineNull() {
111         final ReaderHelper helper = new ReaderHelper(null);
112         final String actual = helper.getLine();
113         assertEquals(null, actual);
114
115     }
116
117 }