2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * ============LICENSE_END=========================================================
24 package org.onap.appc.exceptions;
26 import org.junit.Assert;
27 import org.junit.Test;
28 import org.powermock.reflect.Whitebox;
30 public class UnknownProviderExceptionTest {
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);
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());
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));
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));
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));
83 Whitebox.getInternalState(unknownProviderException, "stackTrace") != null);
84 Assert.assertTrue(Whitebox.getInternalState(unknownProviderException,
85 "suppressedExceptions") != null);
87 unknownProviderException = new UnknownProviderException(message, throwable, false, false);
89 Whitebox.getInternalState(unknownProviderException, "stackTrace") == null);
90 Assert.assertTrue(Whitebox.getInternalState(unknownProviderException,
91 "suppressedExceptions") == null);