2 * ============LICENSE_START=======================================================
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
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 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.onap.appc.exceptions;
27 import org.junit.Assert;
28 import org.junit.Test;
29 import org.powermock.reflect.Whitebox;
31 public class UnknownProviderExceptionTest {
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);
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());
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));
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));
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));
82 Assert.assertTrue(Whitebox.getInternalState(unknownProviderException, "stackTrace") != null);
83 Assert.assertTrue(Whitebox.getInternalState(unknownProviderException,
84 "suppressedExceptions") != null);
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);