Remove impl.ops package and modernize classes a bit.
Change-Id: I4a5f549c2d05cefac544ce1a426815cbc2bc17d8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
* 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.mdsal.notification.impl.ops;
+package org.opendaylight.netconf.mdsal.notification.impl;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
import org.opendaylight.netconf.api.xml.XmlElement;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.mapping.api.SessionAwareNetconfOperation;
-import org.opendaylight.netconf.mdsal.notification.impl.NetconfNotificationManager;
import org.opendaylight.netconf.notifications.NetconfNotification;
import org.opendaylight.netconf.notifications.NetconfNotificationListener;
import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.opendaylight.mdsal.binding.dom.codec.spi.BindingDOMCodecFactory;
import org.opendaylight.mdsal.binding.runtime.api.BindingRuntimeGenerator;
-import org.opendaylight.netconf.mdsal.notification.impl.ops.NotificationsTransformUtil;
import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration;
import org.opendaylight.netconf.notifications.NetconfNotification;
import org.opendaylight.netconf.notifications.NetconfNotificationCollector;
* 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.mdsal.notification.impl;
-import java.util.Collections;
import java.util.Set;
import org.opendaylight.netconf.mapping.api.NetconfOperation;
import org.opendaylight.netconf.mapping.api.NetconfOperationService;
-import org.opendaylight.netconf.mdsal.notification.impl.ops.CreateSubscription;
import org.opendaylight.netconf.notifications.NetconfNotificationRegistry;
-public class NetconfNotificationOperationService implements NetconfOperationService {
- private final Set<NetconfOperation> netconfOperations;
+public final class NetconfNotificationOperationService implements NetconfOperationService {
+ private final CreateSubscription createSubscription;
- public NetconfNotificationOperationService(String netconfSessionIdForReporting, NetconfNotificationRegistry
- netconfNotificationRegistry) {
- this.netconfOperations = Collections.singleton(new CreateSubscription(netconfSessionIdForReporting,
- netconfNotificationRegistry));
+ public NetconfNotificationOperationService(final String netconfSessionIdForReporting,
+ final NetconfNotificationRegistry netconfNotificationRegistry) {
+ createSubscription = new CreateSubscription(netconfSessionIdForReporting, netconfNotificationRegistry);
}
-
@Override
public Set<NetconfOperation> getNetconfOperations() {
- return netconfOperations;
+ return Set.of(createSubscription);
}
@SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void close() {
- for (NetconfOperation netconfOperation : netconfOperations) {
- if (netconfOperation instanceof AutoCloseable) {
- try {
- ((AutoCloseable) netconfOperation).close();
- } catch (Exception e) {
- throw new IllegalStateException("Exception while closing " + netconfOperation, e);
- }
- }
- }
+ createSubscription.close();
}
}
* 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.mdsal.notification.impl.ops;
+package org.opendaylight.netconf.mdsal.notification.impl;
import static com.google.common.base.Verify.verify;
*/
package org.opendaylight.netconf.mdsal.notification.impl;
+import static java.util.Objects.requireNonNull;
+
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
* @param <T> data object class
*/
abstract class OperationalDatastoreListener<T extends DataObject> implements DataTreeChangeListener<T> {
-
private final InstanceIdentifier<T> instanceIdentifier;
/**
* @param instanceIdentifier instance identifier of subtree, on which this instance should listen on changes.
*/
OperationalDatastoreListener(final InstanceIdentifier<T> instanceIdentifier) {
- this.instanceIdentifier = instanceIdentifier;
+ this.instanceIdentifier = requireNonNull(instanceIdentifier);
}
/**
* 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.mdsal.notification.impl.ops;
+package org.opendaylight.netconf.mdsal.notification.impl;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
* 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.mdsal.notification.impl.ops;
+package org.opendaylight.netconf.mdsal.notification.impl;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.mdsal.binding.api.DataBroker;
public class OperationalDatastoreListenerTest {
@Mock
private DataBroker dataBroker;
+ @Captor
+ private ArgumentCaptor<DataTreeIdentifier<?>> argumentId;
@Test
public void testDataStoreListener() {
final InstanceIdentifier<TestInterface> instanceIdentifier = InstanceIdentifier.create(TestInterface.class);
- final DataTreeIdentifier<TestInterface> testId =
- DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
final var op = new OperationalDatastoreListener<>(instanceIdentifier) {
@Override
};
doReturn(null).when(dataBroker).registerDataTreeChangeListener(any(), any());
- ArgumentCaptor<DataTreeIdentifier> argumentId = ArgumentCaptor.forClass(DataTreeIdentifier.class);
op.registerOnChanges(dataBroker);
verify(dataBroker).registerDataTreeChangeListener(argumentId.capture(), any());
- assertEquals(testId, argumentId.getValue());
-
+ assertEquals(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, instanceIdentifier),
+ argumentId.getValue());
}
interface TestInterface extends ChildOf<DataRoot> {