1 package org.openecomp.sdc.exception;
3 import org.junit.Assert;
4 import org.junit.Before;
6 import org.onap.logging.ref.slf4j.ONAPLogConstants;
7 import org.openecomp.sdc.common.log.api.ILogConfiguration;
10 public class AbstractSdncExceptionTest {
12 public void clearMdcTable(){
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);
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);
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);
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);