2 * Copyright (c) 2024 PANTHEON.tech, s.r.o. 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.netconf.client.mdsal.spi;
10 import static org.junit.jupiter.api.Assertions.assertEquals;
13 import org.junit.jupiter.api.AfterEach;
14 import org.junit.jupiter.api.Test;
15 import org.junit.jupiter.api.extension.ExtendWith;
16 import org.mockito.Mock;
17 import org.mockito.junit.jupiter.MockitoExtension;
18 import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
19 import org.opendaylight.yangtools.yang.common.QName;
20 import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier.Absolute;
22 @ExtendWith(MockitoExtension.class)
24 private static final Absolute ONE = Absolute.of(QName.create("test", "one"));
25 private static final Absolute TWO = Absolute.of(QName.create("test", "two"));
27 private final NetconfDeviceNotificationService svc = new NetconfDeviceNotificationService();
30 private DOMNotificationListener listener;
34 assertEquals(0, svc.size());
38 void registerEmpty() {
39 try (var reg = svc.registerNotificationListener(listener)) {
40 assertEquals(0, svc.size());
45 void registerEmptyMap() {
46 try (var reg = svc.registerNotificationListeners(Map.of())) {
47 assertEquals(0, svc.size());
53 try (var reg = svc.registerNotificationListener(listener, ONE)) {
54 assertEquals(1, svc.size());
59 void registerOneMap() {
60 try (var reg = svc.registerNotificationListeners(Map.of(ONE, listener))) {
61 assertEquals(1, svc.size());
66 void registerOneTwo() {
67 try (var reg = svc.registerNotificationListener(listener, ONE, TWO)) {
68 assertEquals(2, svc.size());
73 void registerOneTwoMap() {
74 try (var reg = svc.registerNotificationListeners(Map.of(ONE, listener, TWO, listener))) {
75 assertEquals(2, svc.size());