1 /*******************************************************************************
2 * ============LICENSE_START====================================================
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
11 * * http://www.apache.org/licenses/LICENSE-2.0
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====================================================
21 ******************************************************************************/
22 package org.onap.aaf.client.test;
24 import static org.hamcrest.CoreMatchers.is;
25 import static org.junit.Assert.*;
27 import org.junit.Before;
28 import org.junit.Test;
29 import org.onap.aaf.cadi.client.Result;
31 public class JU_ResultTest {
34 public void setUp() throws Exception {
38 public void testOk() {
39 Result<String> t = Result.ok(1, "Ok");
41 assertThat(t.code, is(1));
43 assertThat(t.toString(), is("Code: 1"));
47 public void testErr() {
48 Result<String> t = Result.err(1, "Error Body");
50 assertThat(t.error, is("Error Body"));
51 assertFalse(t.isOK());
52 assertThat(t.toString(), is("Code: 1 = Error Body"));
56 public void testOk1() {
57 Result<String> t = Result.ok(1, "Ok");
59 assertThat(t.code, is(1));
61 assertThat(t.toString(), is("Code: 1"));
65 public void testErr1() {
66 Result<String> t = Result.err(1, "Error Body");
68 assertThat(t.error, is("Error Body"));
69 assertFalse(t.isOK());
70 assertThat(t.toString(), is("Code: 1 = Error Body"));
74 public void testOk2() {
75 Result<String> t = Result.ok(1, "Ok");
77 assertThat(t.code, is(1));
79 assertThat(t.toString(), is("Code: 1"));
83 public void testErr2() {
84 Result<String> t = Result.err(1, "Error Body");
86 assertThat(t.error, is("Error Body"));
87 assertFalse(t.isOK());
88 assertThat(t.toString(), is("Code: 1 = Error Body"));
92 public void testOk3() {
93 Result<String> t = Result.ok(1, "Ok");
95 assertThat(t.code, is(1));
97 assertThat(t.toString(), is("Code: 1"));
101 public void testErr3() {
102 Result<String> t = Result.err(1, "Error Body");
104 assertThat(t.error, is("Error Body"));
105 assertFalse(t.isOK());
106 assertThat(t.toString(), is("Code: 1 = Error Body"));