3b74df321f3e9781bc21a6a4d6b1b14030738b4f
[ccsdk/features.git] / sdnr / wt / mountpoint-registrar / provider / src / test / java / org / onap / ccsdk / features / sdnr / wt / mountpointregistrar / test / TestCMNotificationBuilder.java
1 /*
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt mountpoint-registrar
4  * =================================================================================================
5  * Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  */
18
19 package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test;
20
21 import static org.junit.Assert.*;
22
23 import org.junit.Test;
24 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMBasicHeaderFieldsNotification;
25 import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMNotification;
26
27 public class TestCMNotificationBuilder {
28
29     private CMNotification cmNotification;
30
31     @Test
32     public void testCMNotificationBuilderWithAllDefinedFields() {
33         cmNotification = cmNotification.builder()
34             .withCMBasicHeaderFieldsNotification(CMBasicHeaderFieldsNotification.builder()
35                 .withCMNodeId("test-node")
36                 .withCMSequence("1")
37                 .withCMOccurrenceTime("2021-10-18T15:25:19.948Z")
38                 .withSourceId("src_device_id_1732")
39                 .withNotificationType("notifyMOIChanges")
40                 .build())
41             .withCMNotificationId("123")
42             .withCMSourceIndicator("UNKNOWN")
43             .withCMPath("http://samsung.com/ves=1")
44             .withCMOperation("CREATE")
45             .withCMValue("value")
46             .build();
47
48         assertEquals("test-node", cmNotification.getBasicHeaderFields().getCmNodeId());
49         assertEquals("1", cmNotification.getBasicHeaderFields().getCmSequence());
50         assertEquals("src_device_id_1732", cmNotification.getBasicHeaderFields().getSourceId());
51         assertEquals("2021-10-18T15:25:19.948Z", cmNotification.getBasicHeaderFields().getCmOccurrenceTime());
52         assertEquals("notifyMOIChanges", cmNotification.getBasicHeaderFields().getNotificationType());
53         assertEquals("123", cmNotification.getCmNotificationId());
54         assertEquals("UNKNOWN", cmNotification.getCmSourceIndicator());
55         assertEquals("http://samsung.com/ves=1", cmNotification.getCmPath());
56         assertEquals("CREATE", cmNotification.getCmOperation());
57         assertEquals("value", cmNotification.getCmValue());
58     }
59
60     @Test
61     public void testCMNotificationBuilderWithDefaultCMOperation() {
62         cmNotification = cmNotification.builder()
63             .withCMBasicHeaderFieldsNotification(CMBasicHeaderFieldsNotification.builder()
64                 .withCMNodeId("test-node")
65                 .withCMSequence("1")
66                 .withCMOccurrenceTime("2021-10-18T15:25:19.948Z")
67                 .withSourceId("src_device_id_1732")
68                 .withNotificationType("notifyMOIChanges")
69                 .build())
70             .withCMNotificationId("123")
71             .withCMSourceIndicator("UNKNOWN")
72             .withCMPath("http://samsung.com/ves=1")
73             .build();
74
75         assertEquals("test-node", cmNotification.getBasicHeaderFields().getCmNodeId());
76         assertEquals("NULL", cmNotification.getCmOperation());
77         assertNull(cmNotification.getCmValue());
78     }
79 }