951f286dd75ff6a72c6d0d92f85dac919249a2d5
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / test / java / org / opendaylight / mdsal / binding / dom / adapter / LazySerializedDOMNotificationTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, 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.mdsal.binding.dom.adapter;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.mockito.ArgumentMatchers.any;
12 import static org.mockito.Mockito.doReturn;
13 import static org.mockito.Mockito.mock;
14
15 import java.time.Instant;
16 import org.junit.Test;
17 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
18 import org.opendaylight.mdsal.dom.api.DOMNotification;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.TwoLevelListChangedBuilder;
20 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
21
22 public class LazySerializedDOMNotificationTest {
23
24     @Test
25     public void basicTest() throws Exception {
26         BindingNormalizedNodeSerializer codec = mock(BindingNormalizedNodeSerializer.class);
27         final DOMNotification lazySerializedDOMNotification =
28                 LazySerializedDOMNotification.create(codec, new TwoLevelListChangedBuilder().build(), Instant.now());
29         ContainerNode containerNode = mock(ContainerNode.class);
30         doReturn(containerNode).when(codec).toNormalizedNodeNotification(any());
31         assertEquals(containerNode, lazySerializedDOMNotification.getBody());
32     }
33 }