Catalog alignment
[sdc.git] / common-app-api / src / test / java / org / openecomp / sdc / exception / AbstractSdncExceptionTest.java
1 package org.openecomp.sdc.exception;
2
3 import org.junit.Assert;
4 import org.junit.Before;
5 import org.junit.Test;
6 import org.onap.logging.ref.slf4j.ONAPLogConstants;
7 import org.openecomp.sdc.common.log.api.ILogConfiguration;
8 import org.slf4j.MDC;
9
10 public class AbstractSdncExceptionTest {
11     @Before
12     public void clearMdcTable(){
13         MDC.clear();
14     }
15
16
17     @Test
18     public void testServiceExceptionEcompRequestIdNull() {
19         String[] variables = {"1234","Test_VF"};
20         ServiceException serviceException = new ServiceException("SVC4628", "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.", variables);
21         String requestId=serviceException.getEcompRequestId();
22         Assert.assertNull(requestId);
23     }
24
25     @Test
26     public void testServiceExceptionEcompRequestIdNotNull() {
27         String[] variables = {"1234","Test_VF"};
28         String expectedRequestId="b819266d-3b92-4e07-aec4-cb7f0d4010a4";
29         MDC.put(ONAPLogConstants.MDCs.REQUEST_ID,expectedRequestId);
30         ServiceException serviceException = new ServiceException("SVC4628", "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.", variables);
31         String requestId=serviceException.getEcompRequestId();
32         Assert.assertEquals(requestId,expectedRequestId);
33     }
34
35
36     @Test
37     public void testPolicyExceptionEcompRequestIdfieldNull() {
38         String[] variables = {"1234","Test_VF"};
39         PolicyException policyexception = new PolicyException("SVC4628", "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.", variables);
40         String requestId=policyexception.getEcompRequestId();
41         Assert.assertNull(requestId);
42     }
43
44     @Test
45     public void testPolicyExceptionEcompRequestIdNotNull() {
46         String[] variables = {"1234","Test_VF"};
47         String expectedRequestId="b819266d-3b92-4e07-aec4-cb7f0d4010a4";
48         MDC.put(ONAPLogConstants.MDCs.REQUEST_ID,expectedRequestId);
49         PolicyException policyexception = new PolicyException("SVC4628", "Error: The VSP with UUID %1 was already imported for VF %2. Please select another or update the existing VF.", variables);
50         String requestId=policyexception.getEcompRequestId();
51         Assert.assertEquals(requestId,expectedRequestId);
52     }
53 }