More license header updates to appc-common files
[appc.git] / appc-common / src / test / java / org / onap / appc / exceptions / UnknownProviderExceptionTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.exceptions;
25
26 import org.junit.Assert;
27 import org.junit.Test;
28 import org.powermock.reflect.Whitebox;
29
30 public class UnknownProviderExceptionTest {
31
32     @Test
33     public void testConstructorNoArgument() throws Exception {
34         UnknownProviderException unknownProviderException = new UnknownProviderException();
35         Assert.assertTrue(unknownProviderException.getCause() == null);
36         Assert.assertTrue(unknownProviderException.getLocalizedMessage() == null);
37         Assert.assertTrue(unknownProviderException.getMessage() == null);
38     }
39
40     @Test
41     public void testConstructorWithMessaqge() throws Exception {
42         String message = "testing message";
43         UnknownProviderException unknownProviderException = new UnknownProviderException(message);
44         Assert.assertTrue(unknownProviderException.getCause() == null);
45         Assert.assertEquals(message, unknownProviderException.getLocalizedMessage());
46         Assert.assertEquals(message, unknownProviderException.getMessage());
47     }
48
49     @Test
50     public void testConstructorWithThrowable() throws Exception {
51         String message = "testing message";
52         Throwable throwable = new Throwable(message);
53         UnknownProviderException unknownProviderException = new UnknownProviderException(throwable);
54         Assert.assertEquals(throwable, unknownProviderException.getCause());
55         Assert.assertTrue(unknownProviderException.getLocalizedMessage().contains(message));
56         Assert.assertTrue(unknownProviderException.getMessage().contains(message));
57     }
58
59     @Test
60     public void testConstructorWithMessageAndThrowable() throws Exception {
61         String message = "testing message";
62         String tMessage = "throwable message";
63         Throwable throwable = new Throwable(tMessage);
64         UnknownProviderException unknownProviderException =
65                 new UnknownProviderException(message, throwable);
66         Assert.assertEquals(throwable, unknownProviderException.getCause());
67         Assert.assertTrue(unknownProviderException.getLocalizedMessage().contains(message));
68         Assert.assertTrue(unknownProviderException.getMessage().contains(message));
69     }
70
71     @Test
72     public void testConstructorWithFourArguements() throws Exception {
73         String message = "testing message";
74         String tMessage = "throwable message";
75         Throwable throwable = new Throwable(tMessage);
76         UnknownProviderException unknownProviderException =
77                 new UnknownProviderException(message, throwable, true, true);
78         Assert.assertEquals(throwable, unknownProviderException.getCause());
79         Assert.assertTrue(unknownProviderException.getLocalizedMessage().contains(message));
80         Assert.assertTrue(unknownProviderException.getMessage().contains(message));
81
82         Assert.assertTrue(
83                 Whitebox.getInternalState(unknownProviderException, "stackTrace") != null);
84         Assert.assertTrue(Whitebox.getInternalState(unknownProviderException,
85                 "suppressedExceptions") != null);
86
87         unknownProviderException = new UnknownProviderException(message, throwable, false, false);
88         Assert.assertTrue(
89                 Whitebox.getInternalState(unknownProviderException, "stackTrace") == null);
90         Assert.assertTrue(Whitebox.getInternalState(unknownProviderException,
91                 "suppressedExceptions") == null);
92     }
93
94 }