Merge "switch drools pdp image to new one"
[integration.git] / test / mocks / mass-pnf-sim / pnf-sim-lightweight / src / test / java / org / onap / pnfsimulator / message / JSONObjectFactoryTest.java
1 /*
2  * ============LICENSE_START=======================================================
3  * PNF-REGISTRATION-HANDLER
4  * ================================================================================
5  * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.pnfsimulator.message;
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertTrue;
25 import static org.onap.pnfsimulator.message.MessageConstants.*;
26
27 import org.json.JSONObject;
28 import org.junit.jupiter.api.Test;
29
30 public class JSONObjectFactoryTest {
31
32     @Test
33     public void generateConstantCommonEventHeader_shouldCreateProperly(){
34         JSONObject commonEventHeader = JSONObjectFactory.generateConstantCommonEventHeader();
35         assertEquals(8,commonEventHeader.toMap().size());
36         assertTrue(commonEventHeader.has(EVENT_ID));
37         assertTrue(commonEventHeader.has(LAST_EPOCH_MICROSEC));
38         assertTrue(commonEventHeader.has(PRIORITY));
39         assertTrue(commonEventHeader.has(SEQUENCE));
40         assertTrue(commonEventHeader.has(START_EPOCH_MICROSEC));
41         assertTrue(commonEventHeader.has(INTERNAL_HEADER_FIELDS));
42         assertTrue(commonEventHeader.has(VERSION));
43         assertEquals(commonEventHeader.get(PRIORITY),PRIORITY_NORMAL);
44         assertEquals(commonEventHeader.get(SEQUENCE),SEQUENCE_NUMBER);
45         assertEquals(commonEventHeader.get(VERSION),VERSION_NUMBER);
46         assertEquals(commonEventHeader.get(VES_EVENT_LISTENER_VERSION),VES_EVENT_LISTENER_VERSION_NUMBER);
47     }
48
49     @Test
50     public void generateConstantPnfRegistrationFields_shouldCreateProperly(){
51         JSONObject pnfRegistrationFields = JSONObjectFactory.generatePnfRegistrationFields();
52         assertEquals(3,pnfRegistrationFields.toMap().size());
53         assertTrue(pnfRegistrationFields.has(PNF_REGISTRATION_FIELDS_VERSION));
54         assertEquals(pnfRegistrationFields.get(PNF_REGISTRATION_FIELDS_VERSION), PNF_REGISTRATION_FIELDS_VERSION_VALUE);
55         assertTrue(pnfRegistrationFields.has(PNF_LAST_SERVICE_DATE));
56         assertTrue(pnfRegistrationFields.has(PNF_MANUFACTURE_DATE));
57     }
58
59     @Test
60     public void generateEventId_shouldCreateProperly(){
61         String eventId = JSONObjectFactory.generateEventId();
62         assertTrue(eventId.startsWith("registration_"));
63     }
64
65     @Test
66     public void generateNotificationFields_shouldCreateProperly(){
67         JSONObject notificationFields = JSONObjectFactory.generateNotificationFields();
68         assertEquals(1,notificationFields.keySet().size());
69         assertEquals(NOTIFICATION_FIELDS_VERSION_VALUE,notificationFields.get(NOTIFICATION_FIELDS_VERSION));
70
71     }
72
73 }