Sonar Fixes, Formatting
[aaf/authz.git] / cadi / client / src / test / java / org / onap / aaf / client / test / JU_ResultTest.java
1 /*******************************************************************************
2  * ============LICENSE_START====================================================
3  * * org.onap.aaf
4  * * ===========================================================================
5  * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * * ===========================================================================
7  * * Licensed under the Apache License, Version 2.0 (the "License");
8  * * you may not use this file except in compliance with the License.
9  * * You may obtain a copy of the License at
10  * *
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * *
13  *  * Unless required by applicable law or agreed to in writing, software
14  * * distributed under the License is distributed on an "AS IS" BASIS,
15  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * * See the License for the specific language governing permissions and
17  * * limitations under the License.
18  * * ============LICENSE_END====================================================
19  * *
20  * *
21  ******************************************************************************/
22
23 package org.onap.aaf.client.test;
24
25 import static org.hamcrest.CoreMatchers.is;
26 import static org.junit.Assert.*;
27
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.aaf.cadi.client.Result;
31
32 public class JU_ResultTest {
33
34     @Before
35     public void setUp() throws Exception {
36     }
37
38     @Test
39     public void testOk() {
40         Result<String> t = Result.ok(1, "Ok");
41         assertNotNull(t);
42         assertThat(t.code, is(1));
43         assertTrue(t.isOK());
44         assertThat(t.toString(), is("Code: 1"));
45     }
46
47     @Test
48     public void testErr() {
49         Result<String> t = Result.err(1, "Error Body");
50         assertNotNull(t);
51         assertThat(t.error, is("Error Body"));
52         assertFalse(t.isOK());
53         assertThat(t.toString(), is("Code: 1 = Error Body"));
54     }
55
56     @Test
57     public void testOk1() {
58         Result<String> t = Result.ok(1, "Ok");
59         assertNotNull(t);
60         assertThat(t.code, is(1));
61         assertTrue(t.isOK());
62         assertThat(t.toString(), is("Code: 1"));
63     }
64
65     @Test
66     public void testErr1() {
67         Result<String> t = Result.err(1, "Error Body");
68         assertNotNull(t);
69         assertThat(t.error, is("Error Body"));
70         assertFalse(t.isOK());
71         assertThat(t.toString(), is("Code: 1 = Error Body"));
72     }
73
74     @Test
75     public void testOk2() {
76         Result<String> t = Result.ok(1, "Ok");
77         assertNotNull(t);
78         assertThat(t.code, is(1));
79         assertTrue(t.isOK());
80         assertThat(t.toString(), is("Code: 1"));
81     }
82
83     @Test
84     public void testErr2() {
85         Result<String> t = Result.err(1, "Error Body");
86         assertNotNull(t);
87         assertThat(t.error, is("Error Body"));
88         assertFalse(t.isOK());
89         assertThat(t.toString(), is("Code: 1 = Error Body"));
90     }
91
92     @Test
93     public void testOk3() {
94         Result<String> t = Result.ok(1, "Ok");
95         assertNotNull(t);
96         assertThat(t.code, is(1));
97         assertTrue(t.isOK());
98         assertThat(t.toString(), is("Code: 1"));
99     }
100
101     @Test
102     public void testErr3() {
103         Result<String> t = Result.err(1, "Error Body");
104         assertNotNull(t);
105         assertThat(t.error, is("Error Body"));
106         assertFalse(t.isOK());
107         assertThat(t.toString(), is("Code: 1 = Error Body"));
108     }
109 }