Refactor NBINotifications and serviceHandlerImpl
[transportpce.git] / nbinotifications / src / test / java / org / opendaylight / transportpce / nbinotifications / serialization / NotificationAlarmServiceDeserializerTest.java
1 /*
2  * Copyright © 2021 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.nbinotifications.serialization;
9
10 import static org.junit.Assert.assertEquals;
11
12 import java.io.IOException;
13 import java.nio.file.Files;
14 import java.nio.file.Paths;
15 import java.util.Map;
16 import org.junit.Test;
17 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
18 import org.opendaylight.transportpce.test.AbstractTest;
19 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.NotificationAlarmService;
20 import org.opendaylight.yang.gen.v1.nbi.notifications.rev210813.get.notifications.alarm.service.output.NotificationsAlarmService;
21
22 public class NotificationAlarmServiceDeserializerTest extends AbstractTest {
23
24     @Test
25     public void deserializeTest() throws IOException {
26         JsonStringConverter<NotificationAlarmService> converter =
27                 new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
28         NotificationAlarmServiceDeserializer deserializer = new NotificationAlarmServiceDeserializer();
29         Map<String, Object> configs = Map.of(ConfigConstants.CONVERTER, converter);
30         deserializer.configure(configs, false);
31         NotificationsAlarmService readEvent = deserializer.deserialize("Test",
32                 Files.readAllBytes(Paths.get("src/test/resources/event_alarm_service.json")));
33         deserializer.close();
34         assertEquals("Service name should be service1", "service1", readEvent.getServiceName());
35         assertEquals("message should be The service is now inService", "The service is now inService",
36                 readEvent.getMessage());
37     }
38 }