3dc4f297deb2bddd61205cca5dd1255a3c122b78
[transportpce.git] / nbinotifications / src / test / java / org / opendaylight / transportpce / nbinotifications / serialization / NotificationTapiServiceDeserializerTest.java
1 /*
2  * Copyright © 2021 Nokia, 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
11 import static org.junit.jupiter.api.Assertions.assertEquals;
12
13 import java.io.IOException;
14 import java.nio.file.Files;
15 import java.nio.file.Paths;
16 import java.util.Map;
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.rev230726.NotificationTapiService;
21 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.notification.rev181210.get.notification.list.output.Notification;
22
23 public class NotificationTapiServiceDeserializerTest extends AbstractTest {
24
25     @Test
26     void deserializeTest() throws IOException {
27         JsonStringConverter<NotificationTapiService> converter = new JsonStringConverter<>(
28                 getDataStoreContextUtil().getBindingDOMCodecServices());
29         TapiNotificationDeserializer deserializer = new TapiNotificationDeserializer();
30         Map<String, Object> configs = Map.of(ConfigConstants.CONVERTER, converter);
31         deserializer.configure(configs, false);
32         Notification readEvent = deserializer.deserialize("76d8f07b-ead5-4132-8eb8-cf3fdef7e079",
33                 Files.readAllBytes(Paths.get("src/test/resources/tapi_event.json")));
34         deserializer.close();
35         assertEquals("76d8f07b-ead5-4132-8eb8-cf3fdef7e079", readEvent.getTargetObjectIdentifier().getValue(),
36             "Service uuid should be 76d8f07b-ead5-4132-8eb8-cf3fdef7e079");
37     }
38 }