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 ******************************************************************************/
23 package org.onap.aaf.client.test;
25 import static org.hamcrest.CoreMatchers.is;
26 import static org.junit.Assert.*;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.aaf.cadi.client.Result;
32 public class JU_ResultTest {
35 public void setUp() throws Exception {
39 public void testOk() {
40 Result<String> t = Result.ok(1, "Ok");
42 assertThat(t.code, is(1));
44 assertThat(t.toString(), is("Code: 1"));
48 public void testErr() {
49 Result<String> t = Result.err(1, "Error Body");
51 assertThat(t.error, is("Error Body"));
52 assertFalse(t.isOK());
53 assertThat(t.toString(), is("Code: 1 = Error Body"));
57 public void testOk1() {
58 Result<String> t = Result.ok(1, "Ok");
60 assertThat(t.code, is(1));
62 assertThat(t.toString(), is("Code: 1"));
66 public void testErr1() {
67 Result<String> t = Result.err(1, "Error Body");
69 assertThat(t.error, is("Error Body"));
70 assertFalse(t.isOK());
71 assertThat(t.toString(), is("Code: 1 = Error Body"));
75 public void testOk2() {
76 Result<String> t = Result.ok(1, "Ok");
78 assertThat(t.code, is(1));
80 assertThat(t.toString(), is("Code: 1"));
84 public void testErr2() {
85 Result<String> t = Result.err(1, "Error Body");
87 assertThat(t.error, is("Error Body"));
88 assertFalse(t.isOK());
89 assertThat(t.toString(), is("Code: 1 = Error Body"));
93 public void testOk3() {
94 Result<String> t = Result.ok(1, "Ok");
96 assertThat(t.code, is(1));
98 assertThat(t.toString(), is("Code: 1"));
102 public void testErr3() {
103 Result<String> t = Result.err(1, "Error Body");
105 assertThat(t.error, is("Error Body"));
106 assertFalse(t.isOK());
107 assertThat(t.toString(), is("Code: 1 = Error Body"));