2 * Copyright © 2021 Orange, Inc. and others. All rights reserved.
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
8 package org.opendaylight.transportpce.nbinotifications.serialization;
11 import static org.junit.jupiter.api.Assertions.assertEquals;
13 import java.io.IOException;
14 import java.nio.file.Files;
15 import java.nio.file.Paths;
17 import org.junit.jupiter.api.Test;
18 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
19 import org.opendaylight.transportpce.test.AbstractTest;
20 import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.NotificationAlarmService;
21 import org.opendaylight.yang.gen.v1.nbi.notifications.rev230728.get.notifications.alarm.service.output.NotificationsAlarmService;
23 public class NotificationAlarmServiceDeserializerTest extends AbstractTest {
26 void deserializeTest() throws IOException {
27 JsonStringConverter<NotificationAlarmService> converter =
28 new JsonStringConverter<>(getDataStoreContextUtil().getBindingDOMCodecServices());
29 NotificationAlarmServiceDeserializer deserializer = new NotificationAlarmServiceDeserializer();
30 Map<String, Object> configs = Map.of(ConfigConstants.CONVERTER, converter);
31 deserializer.configure(configs, false);
32 NotificationsAlarmService readEvent = deserializer.deserialize("Test",
33 Files.readAllBytes(Paths.get("src/test/resources/event_alarm_service.json")));
35 assertEquals("service1", readEvent.getServiceName(), "Service name should be service1");
36 assertEquals("The service is now inService", readEvent.getMessage(),
37 "message should be The service is now inService");