From c210851e3a576ee4c4238021a43a604899650515 Mon Sep 17 00:00:00 2001 From: Ivan Hrasko Date: Thu, 10 Mar 2022 13:41:37 +0100 Subject: [PATCH] Remove NodeContainerProxy class NodeContainerProxy is marked deprecated since the version 2.0.0 remove it for version 3.0.0. This way we do not have to spend time to maintain not used class. JIRA: NETCONF-865 Change-Id: I35bd055a938556a384fd69127113f4bc92239bd7 Signed-off-by: Ivan Hrasko --- .../netconf/util/NodeContainerProxy.java | 171 ------------------ .../netconf/util/NodeContainerProxyTest.java | 143 --------------- 2 files changed, 314 deletions(-) delete mode 100644 netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NodeContainerProxy.java delete mode 100644 netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NodeContainerProxyTest.java diff --git a/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NodeContainerProxy.java b/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NodeContainerProxy.java deleted file mode 100644 index 139509a0e7..0000000000 --- a/netconf/netconf-util/src/main/java/org/opendaylight/netconf/util/NodeContainerProxy.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.util; - -import static java.util.Objects.requireNonNull; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.Maps; -import java.util.Collection; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import org.eclipse.jdt.annotation.NonNull; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.ActionDefinition; -import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; -import org.opendaylight.yangtools.yang.model.api.GroupingDefinition; -import org.opendaylight.yangtools.yang.model.api.MustDefinition; -import org.opendaylight.yangtools.yang.model.api.NotificationDefinition; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.opendaylight.yangtools.yang.model.api.Status; -import org.opendaylight.yangtools.yang.model.api.TypeDefinition; -import org.opendaylight.yangtools.yang.model.api.UsesNode; -import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement; -import org.opendaylight.yangtools.yang.xpath.api.YangXPathExpression.QualifiedBound; - -/** - * Simple proxy for container like schema nodes, where user provides a collection of children schema nodes. - * - * @deprecated This class is no longer used anywhere and is scheduled for removal. - */ -@Deprecated(since = "2.0.0", forRemoval = true) -public final class NodeContainerProxy implements ContainerSchemaNode { - private final Collection availableAugmentations; - private final @NonNull Map childNodes; - private final @NonNull SchemaPath path; - private final @NonNull QName qname; - - @VisibleForTesting - NodeContainerProxy(final QName qname, final SchemaPath path, final Map childNodes, - final Collection availableAugmentations) { - this.qname = requireNonNull(qname); - this.path = requireNonNull(path); - this.childNodes = requireNonNull(childNodes); - this.availableAugmentations = availableAugmentations; - } - - public static @NonNull NodeContainerProxy ofModelContext(final QName qname, final EffectiveModelContext context) { - return new NodeContainerProxy(qname, SchemaPath.ROOT, asMap(context.getChildNodes()), Set.of()); - } - - public static @NonNull NodeContainerProxy ofNotification(final NotificationDefinition notification) { - return new NodeContainerProxy(notification.getQName(), notification.getPath(), - asMap(notification.getChildNodes()), notification.getAvailableAugmentations()); - } - - private static Map asMap(final Collection childNodes) { - return Maps.uniqueIndex(childNodes, DataSchemaNode::getQName); - } - - @Override - public Collection> getTypeDefinitions() { - return Set.of(); - } - - @Override - public Collection getChildNodes() { - return childNodes.values(); - } - - @Override - public Collection getGroupings() { - return Set.of(); - } - - @Override - public DataSchemaNode dataChildByName(final QName name) { - return childNodes.get(name); - } - - @Override - public Collection getUses() { - return Set.of(); - } - - @Override - public boolean isPresenceContainer() { - throw new UnsupportedOperationException(); - } - - @Override - public Collection getAvailableAugmentations() { - return availableAugmentations; - } - - @Override - @Deprecated - public boolean isAugmenting() { - throw new UnsupportedOperationException(); - } - - @Override - @Deprecated - public boolean isAddedByUses() { - throw new UnsupportedOperationException(); - } - - @Override - public Optional effectiveConfig() { - throw new UnsupportedOperationException(); - } - - @Override - public QName getQName() { - return qname; - } - - @Override - @Deprecated - public SchemaPath getPath() { - return path; - } - - @Override - public Optional getDescription() { - throw new UnsupportedOperationException(); - } - - @Override - public Optional getReference() { - throw new UnsupportedOperationException(); - } - - @Override - public Status getStatus() { - throw new UnsupportedOperationException(); - } - - @Override - public Collection getNotifications() { - return Set.of(); - } - - @Override - public Collection getActions() { - return Set.of(); - } - - @Override - public Optional getWhenCondition() { - return Optional.empty(); - } - - @Override - public Collection getMustConstraints() { - return Set.of(); - } - - @Override - public ContainerEffectiveStatement asEffectiveStatement() { - throw new UnsupportedOperationException(); - } -} diff --git a/netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NodeContainerProxyTest.java b/netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NodeContainerProxyTest.java deleted file mode 100644 index d0a352828b..0000000000 --- a/netconf/netconf-util/src/test/java/org/opendaylight/netconf/util/NodeContainerProxyTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.netconf.util; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertThrows; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; - -@RunWith(MockitoJUnitRunner.StrictStubs.class) -public class NodeContainerProxyTest { - private static final QName QNAME = QName.create("ns", "2016-10-19", "name"); - private static final QName NODE_1_QNAME = QName.create(QNAME, "node-1"); - private static final QName NODE_2_QNAME = QName.create(QNAME, "node-2"); - - @Mock - private AugmentationSchemaNode augSchema1; - @Mock - private AugmentationSchemaNode augSchema2; - @Mock - private DataSchemaNode schemaNode1; - @Mock - private DataSchemaNode schemaNode2; - private NodeContainerProxy proxy; - - @Before - public void setUp() { - proxy = new NodeContainerProxy(QNAME, SchemaPath.SAME, - Map.of(NODE_1_QNAME, schemaNode1, NODE_2_QNAME, schemaNode2), Set.of(augSchema1, augSchema2)); - } - - @Test - public void testGetQName() { - assertSame(QNAME, proxy.getQName()); - } - - @Test - @Deprecated - public void testGetPath() { - assertSame(SchemaPath.SAME, proxy.getPath()); - } - - @Test - public void testGetChildNodes() { - final var children = proxy.getChildNodes(); - assertEquals(2, children.size()); - assertThat(children, containsInAnyOrder(schemaNode1, schemaNode2)); - } - - @Test - public void testGetAvailableAugmentations() { - final var augmentations = proxy.getAvailableAugmentations(); - assertEquals(2, augmentations.size()); - assertThat(augmentations, containsInAnyOrder(augSchema1, augSchema2)); - } - - @Test - public void testFindDataChildByName() { - assertEquals(Optional.of(schemaNode1), proxy.findDataChildByName(NODE_1_QNAME)); - } - - @Test - public void testGetTypeDefinitions() { - assertEmpty(proxy.getTypeDefinitions()); - } - - @Test - public void testGetGroupings() { - assertEmpty(proxy.getGroupings()); - } - - @Test - public void testGetUses() { - assertEmpty(proxy.getUses()); - } - - @Test - public void testGetUnknownSchemaNodes() { - assertEmpty(proxy.getUnknownSchemaNodes()); - } - - @Test - public void testIsPresenceContainer() { - assertThrows(UnsupportedOperationException.class, () -> proxy.isPresenceContainer()); - } - - @Test - @Deprecated - public void testIsAugmenting() { - assertThrows(UnsupportedOperationException.class, () -> proxy.isAugmenting()); - } - - @Test - @Deprecated - public void testIsAddedByUses() { - assertThrows(UnsupportedOperationException.class, () -> proxy.isAddedByUses()); - } - - @Test - public void testIsConfiguration() { - assertThrows(UnsupportedOperationException.class, () -> proxy.isConfiguration()); - } - - @Test - public void testGetDescription() { - assertThrows(UnsupportedOperationException.class, () -> proxy.getDescription()); - } - - @Test - public void testGetReference() { - assertThrows(UnsupportedOperationException.class, () -> proxy.getReference()); - } - - @Test - public void testGetStatus() { - assertThrows(UnsupportedOperationException.class, () -> proxy.getStatus()); - } - - static void assertEmpty(final Collection coll) { - assertEquals(List.of(), List.copyOf(coll)); - } -} -- 2.36.6