2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 TechMahindra
6 * Copyright (c) 2022, Samsung Electronics. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
21 package org.onap.so.adapters.requestsdb.exceptions;
23 import org.junit.Assert;
24 import org.junit.Test;
26 public class MsoRequestsDbExceptionTest {
28 public void testConstructorWithMessaqge() throws Exception {
29 String message = "testing message";
30 MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(message);
31 Assert.assertNull(msoRequestsDbException.getCause());
32 Assert.assertEquals(message, msoRequestsDbException.getLocalizedMessage());
33 Assert.assertEquals(message, msoRequestsDbException.getMessage());
37 public void testConstructorWithThrowable() throws Exception {
38 String message = "testing message";
39 Throwable throwable = new Throwable(message);
40 MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(throwable);
41 Assert.assertEquals(throwable, msoRequestsDbException.getCause());
42 Assert.assertTrue(msoRequestsDbException.getLocalizedMessage().contains(message));
43 Assert.assertTrue(msoRequestsDbException.getMessage().contains(message));
47 public void testConstructorWithMessageAndThrowable() throws Exception {
48 String message = "testing message";
49 String tMessage = "throwable message";
50 Throwable throwable = new Throwable(tMessage);
51 MsoRequestsDbException msoRequestsDbException = new MsoRequestsDbException(message, throwable);
52 Assert.assertEquals(throwable, msoRequestsDbException.getCause());
53 Assert.assertTrue(msoRequestsDbException.getLocalizedMessage().contains(message));
54 Assert.assertTrue(msoRequestsDbException.getMessage().contains(message));
59 public void testGetFaultInfo() {
60 MsoRequestsDbExceptionBean faultInfo = new MsoRequestsDbExceptionBean();
61 MsoRequestsDbException soRequestsDbException = new MsoRequestsDbException("message");
62 soRequestsDbException.setFaultInfo(faultInfo);
63 Assert.assertNotNull(soRequestsDbException.getFaultInfo());
64 Assert.assertEquals(soRequestsDbException.getFaultInfo(), faultInfo);