1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package org.openecomp.sdc.exception;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.openecomp.sdc.common.log.api.ILogConfiguration;
import org.slf4j.MDC;
public class AbstractSdncExceptionTest {
@Before
public void clearMdcTable(){
MDC.clear();
}
@Test
public void testServiceExceptionEcompRequestIdNull() {
String[] variables = {"1234","Test_VF"};
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);
String requestId=serviceException.getEcompRequestId();
Assert.assertNull(requestId);
}
@Test
public void testServiceExceptionEcompRequestIdNotNull() {
String[] variables = {"1234","Test_VF"};
String expectedRequestId="b819266d-3b92-4e07-aec4-cb7f0d4010a4";
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID,expectedRequestId);
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);
String requestId=serviceException.getEcompRequestId();
Assert.assertEquals(requestId,expectedRequestId);
}
@Test
public void testPolicyExceptionEcompRequestIdfieldNull() {
String[] variables = {"1234","Test_VF"};
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);
String requestId=policyexception.getEcompRequestId();
Assert.assertNull(requestId);
}
@Test
public void testPolicyExceptionEcompRequestIdNotNull() {
String[] variables = {"1234","Test_VF"};
String expectedRequestId="b819266d-3b92-4e07-aec4-cb7f0d4010a4";
MDC.put(ONAPLogConstants.MDCs.REQUEST_ID,expectedRequestId);
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);
String requestId=policyexception.getEcompRequestId();
Assert.assertEquals(requestId,expectedRequestId);
}
}
|