d3fc15d3bd2d56d881f2c07c6dc05920c1689c48
[appc.git] / appc-common / src / test / java / org / openecomp / appc / exceptions / UnknownProviderExceptionTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.openecomp.appc.exceptions;
26
27 import org.junit.Assert;
28 import org.junit.Test;
29 import org.powermock.reflect.Whitebox;
30
31 public class UnknownProviderExceptionTest {
32
33     @Test
34     public void testConstructorNoArgument() throws Exception {
35         UnknownProviderException unknownProviderException = new UnknownProviderException();
36         Assert.assertTrue(unknownProviderException.getCause() == null);
37         Assert.assertTrue(unknownProviderException.getLocalizedMessage() == null);
38         Assert.assertTrue(unknownProviderException.getMessage() == null);
39     }
40
41     @Test
42     public void testConstructorWithMessaqge() throws Exception {
43         String message = "testing message";
44         UnknownProviderException unknownProviderException = new UnknownProviderException(message);
45         Assert.assertTrue(unknownProviderException.getCause() == null);
46         Assert.assertEquals(message, unknownProviderException.getLocalizedMessage());
47         Assert.assertEquals(message, unknownProviderException.getMessage());
48     }
49
50     @Test
51     public void testConstructorWithThrowable() throws Exception {
52         String message = "testing message";
53         Throwable throwable = new Throwable(message);
54         UnknownProviderException unknownProviderException = new UnknownProviderException(throwable);
55         Assert.assertEquals(throwable, unknownProviderException.getCause());
56         Assert.assertTrue(unknownProviderException.getLocalizedMessage().contains(message));
57         Assert.assertTrue(unknownProviderException.getMessage().contains(message));
58     }
59
60     @Test
61     public void testConstructorWithMessageAndThrowable() throws Exception {
62         String message = "testing message";
63         String tMessage = "throwable message";
64         Throwable throwable = new Throwable(tMessage);
65         UnknownProviderException unknownProviderException = 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(Whitebox.getInternalState(unknownProviderException, "stackTrace") != null);
83         Assert.assertTrue(Whitebox.getInternalState(unknownProviderException,
84                 "suppressedExceptions") != null);
85
86         unknownProviderException = new UnknownProviderException(message, throwable, false, false);
87         Assert.assertTrue(Whitebox.getInternalState(unknownProviderException,
88                 "stackTrace") == null);
89         Assert.assertTrue(Whitebox.getInternalState(unknownProviderException,
90                 "suppressedExceptions") == null);
91     }
92
93 }