Junit for ServiceException
[vfc/nfvo/driver/vnfm/svnfm.git] / huawei / vnfmadapter / VnfmadapterService / service / src / test / java / org / onap / vfc / nfvo / vnfm / svnfm / vnfmadapter / common / restclient / ServiceExceptionTest.java
1 /*
2  * Copyright 2017 Huawei Technologies Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onap.vfc.nfvo.vnfm.svnfm.vnfmadapter.common.restclient;
17
18 import static org.junit.Assert.assertNotNull;
19 import static org.junit.Assert.assertNull;
20
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23
24 import mockit.integration.junit4.JMockit;
25 @RunWith(JMockit.class)
26 public class ServiceExceptionTest {
27         
28         @Test
29         public void test() {
30                 ServiceException serviceException = new ServiceException();
31                 ServiceException serviceWithThrowable = new ServiceException("id",new Throwable());
32                 ServiceException serviceWithThrowableMessage = new ServiceException("id","message",new Throwable());
33
34                 ServiceException serviceWithMessage = new ServiceException("message");
35                 ServiceException serviceWithID = new ServiceException("id","message");
36                 ServiceException serviceWithHttpCode = new ServiceException("id",200);
37                 ServiceException serviceWithHttpCodeAndMessage = new ServiceException(200,"message");
38                 ServiceException serviceWithexceptionArgs = new ServiceException("id",200,new ExceptionArgs());
39                 ServiceException serviceWithMessageThowable =new ServiceException("id","message","args","args");
40                 ServiceException serviceWithThowableAndArgs =new ServiceException("id","message",new Throwable(),"args");
41                 assertNotNull(serviceWithThowableAndArgs.getArgs());
42                 assertNotNull(serviceWithID.getId());
43                 assertNotNull(serviceWithexceptionArgs.getExceptionArgs());
44                 assertNotNull(serviceWithThowableAndArgs.getArgs());
45         }
46 }