@Override
protected void applyTo(final ClientSession session) {
Preconditions.checkArgument(session instanceof ClientSessionImpl);
- ((ClientSessionImpl) session).setUsername(username);
+ session.setUsername(username);
// First try authentication using server host keys, else try password.
for (KeyPair keyPair : clientKeyPair) {
final Datastore targetDatastore = extractTargetParameter(operationElement);
if (targetDatastore == Datastore.candidate) {
LOG.debug("Locking candidate datastore on session: {}", getNetconfSessionIdForReporting());
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
throw new DocumentedException("Unable to lock " + targetDatastore + " datastore",
final Datastore targetDatastore = Lock.extractTargetParameter(operationElement);
if (targetDatastore == Datastore.candidate) {
LOG.debug("Unlocking candidate datastore on session: {}", getNetconfSessionIdForReporting());
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
throw new DocumentedException("Unable to unlock " + targetDatastore + " datastore",
return sourceElement.isPresent()
? Optional.of(Datastore.valueOf(sourceElement.get().getOnlyChildElement().getName()))
- : Optional.<Datastore>absent();
+ : Optional.absent();
}
private static void validateInputRpc(final XmlElement xml, final String operationName) throws
final Optional<YangInstanceIdentifier> dataRootOptional = getDataRootFromFilter(operationElement);
if (!dataRootOptional.isPresent()) {
- return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.absent());
}
final YangInstanceIdentifier dataRoot = dataRootOptional.get();
transactionProvider.abortRunningTransaction(rwTx);
if (!normalizedNodeOptional.isPresent()) {
- return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.absent());
}
return serializeNodeWithParentStructure(document, dataRoot, normalizedNodeOptional.get());
final Optional<YangInstanceIdentifier> dataRootOptional = getDataRootFromFilter(operationElement);
if (!dataRootOptional.isPresent()) {
- return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.absent());
}
final YangInstanceIdentifier dataRoot = dataRootOptional.get();
}
if (!normalizedNodeOptional.isPresent()) {
- return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.DATA_KEY, Optional.absent());
}
return serializeNodeWithParentStructure(document, dataRoot, normalizedNodeOptional.get());
netconfCapabilityChangeBuilder.setAddedCapability(ImmutableList.copyOf(added));
netconfCapabilityChangeBuilder.setDeletedCapability(ImmutableList.copyOf(removed));
// TODO modified should be computed ... but why ?
- netconfCapabilityChangeBuilder.setModifiedCapability(Collections.<Uri>emptyList());
+ netconfCapabilityChangeBuilder.setModifiedCapability(Collections.emptyList());
baseNotificationPublisherRegistration.onCapabilityChanged(netconfCapabilityChangeBuilder.build());
}
Map<InstanceIdentifier<?>, DataObject> createdData = Maps.newHashMap();
createdData.put(capabilitiesIdentifier, newCapabilities);
verifyDataTreeChange(DataObjectModification.ModificationType.WRITE, null, newCapabilities,
- changedCapabilitesFrom(newCapabilitiesList, Collections.<Uri>emptyList()));
+ changedCapabilitesFrom(newCapabilitiesList, Collections.emptyList()));
}
@Test
netconfCapabilityChangeBuilder.setChangedBy(new ChangedByBuilder().setServerOrUser(
new ServerBuilder().setServer(true).build()).build());
- netconfCapabilityChangeBuilder.setModifiedCapability(Collections.<Uri>emptyList());
+ netconfCapabilityChangeBuilder.setModifiedCapability(Collections.emptyList());
netconfCapabilityChangeBuilder.setAddedCapability(added);
netconfCapabilityChangeBuilder.setDeletedCapability(deleted);
public DocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
final ErrorSeverity errorSeverity) {
- this(message, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+ this(message, errorType, errorTag, errorSeverity, Collections.emptyMap());
}
public DocumentedException(final String message, final ErrorType errorType, final ErrorTag errorTag,
public DocumentedException(final String message, final Exception cause, final ErrorType errorType,
final ErrorTag errorTag, final ErrorSeverity errorSeverity) {
- this(message, cause, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+ this(message, cause, errorType, errorTag, errorSeverity, Collections.emptyMap());
}
public DocumentedException(final String message, final Exception cause, final ErrorType errorType,
public MissingNameSpaceException(final String message, final DocumentedException.ErrorType errorType,
final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorSeverity errorSeverity) {
- this(message, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+ this(message, errorType, errorTag, errorSeverity, Collections.emptyMap());
}
public MissingNameSpaceException(final String message, final DocumentedException.ErrorType errorType,
public UnexpectedElementException(final String message, final DocumentedException.ErrorType errorType,
final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorSeverity errorSeverity) {
- this(message, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+ this(message, errorType, errorTag, errorSeverity, Collections.emptyMap());
}
public UnexpectedElementException(final String message, final DocumentedException.ErrorType errorType,
public UnexpectedNamespaceException(final String message, final DocumentedException.ErrorType errorType,
final DocumentedException.ErrorTag errorTag, final DocumentedException.ErrorSeverity errorSeverity) {
- this(message, errorType, errorTag, errorSeverity, Collections.<String, String>emptyMap());
+ this(message, errorType, errorTag, errorSeverity, Collections.emptyMap());
}
public UnexpectedNamespaceException(final String message, final DocumentedException.ErrorType errorType,
}
public void checkUnrecognisedElements(final XmlElement... additionalRecognisedElements) throws DocumentedException {
- checkUnrecognisedElements(Collections.<XmlElement>emptyList(), additionalRecognisedElements);
+ checkUnrecognisedElements(Collections.emptyList(), additionalRecognisedElements);
}
@Override
final String prefix, final String namespace, final String contentWithoutPrefix) {
return createTextElementWithNamespacedContent(document, qname, prefix, namespace, contentWithoutPrefix,
- Optional.<String>absent());
+ Optional.absent());
}
public static Element createTextElementWithNamespacedContent(final Document document, final String qname,
}
public final synchronized Future<NetconfMessage> sendRequest(NetconfMessage message) {
- final RequestEntry req = new RequestEntry(GlobalEventExecutor.INSTANCE.<NetconfMessage>newPromise(), message);
+ final RequestEntry req = new RequestEntry(GlobalEventExecutor.INSTANCE.newPromise(), message);
requests.add(req);
if (clientSession != null) {
import io.netty.util.Timer;
import io.netty.util.concurrent.Promise;
import org.junit.Test;
-import org.opendaylight.netconf.api.messages.NetconfHelloMessageAdditionalHeader;
import org.opendaylight.protocol.framework.SessionListenerFactory;
import org.opendaylight.protocol.framework.SessionNegotiator;
Channel channel = mock(Channel.class);
Promise<NetconfClientSession> promise = mock(Promise.class);
NetconfClientSessionNegotiatorFactory negotiatorFactory = new NetconfClientSessionNegotiatorFactory(timer,
- Optional.<NetconfHelloMessageAdditionalHeader>absent(), 200L);
+ Optional.absent(), 200L);
SessionNegotiator<?> sessionNegotiator = negotiatorFactory.getSessionNegotiator(listenerFactory, channel,
promise);
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelPipeline;
import io.netty.util.concurrent.Promise;
-
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
DocumentedException.ErrorSeverity.ERROR, Collections.singletonMap(
DocumentedException.ErrorSeverity.ERROR.toString(), e.getMessage()));
}
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
@Override
netconfCapabilityChangeBuilder.setAddedCapability(Lists.newArrayList(Collections2
.transform(added, CAPABILITY_TO_URI)));
// TODO modified should be computed ... but why ?
- netconfCapabilityChangeBuilder.setModifiedCapability(Collections.<Uri>emptyList());
+ netconfCapabilityChangeBuilder.setModifiedCapability(Collections.emptyList());
return netconfCapabilityChangeBuilder.build();
}
import org.opendaylight.netconf.util.messages.NetconfMessageUtil;
import org.opendaylight.netconf.util.test.XmlFileLoader;
import org.opendaylight.protocol.framework.NeverReconnectStrategy;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.CapabilitiesBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}).when(monitoring).registerCapabilitiesListener(any(NetconfMonitoringService.CapabilitiesListener.class));
doReturn(sessionListener).when(monitoring).getSessionListener();
- doReturn(new CapabilitiesBuilder().setCapability(Collections.<Uri>emptyList()).build()).when(monitoring)
+ doReturn(new CapabilitiesBuilder().setCapability(Collections.emptyList()).build()).when(monitoring)
.getCapabilities();
return monitoring;
}
}
assertTrue(messages.isEmpty());
- NetconfMessage receivedMessage = (NetconfMessage) testChunkChannel.readInbound();
+ NetconfMessage receivedMessage = testChunkChannel.readInbound();
assertNotNull(receivedMessage);
assertXMLEqual(this.msg.getDocument(), receivedMessage.getDocument());
}
new NetconfMessageToXMLEncoder(), new NetconfEOMAggregator(), new NetconfXMLToMessageDecoder());
testChunkChannel.writeOutbound(this.msg);
- ByteBuf recievedOutbound = (ByteBuf) testChunkChannel.readOutbound();
+ ByteBuf recievedOutbound = testChunkChannel.readOutbound();
byte[] endOfMsgBytes = NetconfMessageConstants.END_OF_MESSAGE.getBytes(StandardCharsets.UTF_8);
byte[] eom = new byte[endOfMsgBytes.length];
assertArrayEquals(endOfMsgBytes, eom);
testChunkChannel.writeInbound(recievedOutbound);
- NetconfMessage receivedMessage = (NetconfMessage) testChunkChannel.readInbound();
+ NetconfMessage receivedMessage = testChunkChannel.readInbound();
assertNotNull(receivedMessage);
assertXMLEqual(this.msg.getDocument(), receivedMessage.getDocument());
}
listener.onMessage(session, msg);
verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.IN_RPC_SUCCESS)));
channel.runPendingTasks();
- final NetconfMessage sentMsg = (NetconfMessage) channel.readOutbound();
+ final NetconfMessage sentMsg = channel.readOutbound();
final Diff diff = XMLUnit.compareXML(reply, sentMsg.getDocument());
Assert.assertTrue(diff.toString(), diff.similar());
}
verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.IN_RPC_FAIL)));
verify(monitoringListener).onSessionEvent(argThat(sessionEventIs(SessionEvent.Type.OUT_RPC_ERROR)));
channel.runPendingTasks();
- final NetconfMessage sentMsg = (NetconfMessage) channel.readOutbound();
+ final NetconfMessage sentMsg = channel.readOutbound();
System.out.println(XmlUtil.toString(sentMsg.getDocument()));
System.out.println(XmlUtil.toString(reply));
final Diff diff = XMLUnit.compareXML(reply, sentMsg.getDocument());
@Override
public Set<NetconfOperation> getNetconfOperations() {
- return Sets.<NetconfOperation>newHashSet(new Get(monitor), new GetSchema(monitor));
+ return Sets.newHashSet(new Get(monitor), new GetSchema(monitor));
}
@Override
import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SchemasBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.SessionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.sessions.Session;
import org.w3c.dom.Document;
public class GetTest {
correctSubsequentResult = XmlUtil.readXmlToDocument("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:"
+ "1.0\"><data></data></rpc-reply>");
- doReturn(new SessionsBuilder().setSession(Collections.<Session>emptyList()).build()).when(monitor)
+ doReturn(new SessionsBuilder().setSession(Collections.emptyList()).build()).when(monitor)
.getSessions();
- doReturn(new SchemasBuilder().setSchema(Collections.<Schema>emptyList()).build()).when(monitor).getSchemas();
+ doReturn(new SchemasBuilder().setSchema(Collections.emptyList()).build()).when(monitor).getSchemas();
doReturn(false).when(subsequentOperation).isExecutionTermination();
get = new Get(monitor);
private static Optional<SslHandler> getSslHandler(final Channel channel) {
final SslHandler sslHandler = channel.pipeline().get(SslHandler.class);
- return sslHandler == null ? Optional.<SslHandler>absent() : Optional.of(sslHandler);
+ return sslHandler == null ? Optional.absent() : Optional.of(sslHandler);
}
public P getSessionPreferences() {
private final Optional<String> clientId;
public NetconfMessageToXMLEncoder() {
- this(Optional.<String>absent());
+ this(Optional.absent());
}
public NetconfMessageToXMLEncoder(final Optional<String> clientId) {
public void onSuccess(final SshFutureListener<IoReadFuture> result) {
doReturn(new IllegalStateException()).when(mockedReadFuture).getException();
doReturn(mockedReadFuture).when(mockedReadFuture)
- .removeListener(Matchers.<SshFutureListener<IoReadFuture>>any());
+ .removeListener(Matchers.any());
doReturn(true).when(asyncOut).isClosing();
doReturn(true).when(asyncOut).isClosed();
result.operationComplete(mockedReadFuture);
public void onSuccess(final SshFutureListener<IoReadFuture> result) {
doReturn(new IllegalStateException()).when(mockedReadFuture).getException();
doReturn(mockedReadFuture).when(mockedReadFuture)
- .removeListener(Matchers.<SshFutureListener<IoReadFuture>>any());
+ .removeListener(Matchers.any());
result.operationComplete(mockedReadFuture);
}
}, MoreExecutors.directExecutor());
private static IoOutputStream getMockedIoOutputStream() {
final IoOutputStream mock = mock(IoOutputStream.class);
final IoWriteFuture ioWriteFuture = mock(IoWriteFuture.class);
- doReturn(ioWriteFuture).when(ioWriteFuture).addListener(Matchers.<SshFutureListener<IoWriteFuture>>any());
+ doReturn(ioWriteFuture).when(ioWriteFuture).addListener(Matchers.any());
doReturn(true).when(ioWriteFuture).isWritten();
Futures.addCallback(stubAddListener(ioWriteFuture), new SuccessFutureListener<IoWriteFuture>() {
final IoInputStream mock = mock(IoInputStream.class);
final IoReadFuture ioReadFuture = mock(IoReadFuture.class);
doReturn(null).when(ioReadFuture).getException();
- doReturn(ioReadFuture).when(ioReadFuture).removeListener(Matchers.<SshFutureListener<IoReadFuture>>any());
+ doReturn(ioReadFuture).when(ioReadFuture).removeListener(Matchers.any());
doReturn(5).when(ioReadFuture).getRead();
doReturn(new ByteArrayBuffer(new byte[]{0, 1, 2, 3, 4})).when(ioReadFuture).getBuffer();
- doReturn(ioReadFuture).when(ioReadFuture).addListener(Matchers.<SshFutureListener<IoReadFuture>>any());
+ doReturn(ioReadFuture).when(ioReadFuture).addListener(Matchers.any());
// Always success for read
Futures.addCallback(stubAddListener(ioReadFuture), new SuccessFutureListener<IoReadFuture>() {
.registerNotificationListener(streamNameType, new NotificationSubscription(netconfSession, filter));
subscriptions.add(notificationListenerRegistration);
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
private static StreamNameType parseStreamIfPresent(final XmlElement operationElement) throws DocumentedException {
* Transform base notification for capabilities into NetconfNotification.
*/
public static NetconfNotification transform(final Notification notification, SchemaPath path) {
- return transform(notification, Optional.<Date>absent(), path);
+ return transform(notification, Optional.absent(), path);
}
public static NetconfNotification transform(final Notification notification,
final NetconfOperationServiceFactory netconfOperationServiceFactory = new NetconfOperationServiceFactory() {
private final Set<Capability> capabilities =
- Collections.<Capability>singleton(new BasicCapability(NetconfNotification.NOTIFICATION_NAMESPACE));
+ Collections.singleton(new BasicCapability(NetconfNotification.NOTIFICATION_NAMESPACE));
@Override
public Set<Capability> getCapabilities() {
@Override
public AutoCloseable registerCapabilityListener(final CapabilityListener listener) {
- listener.onCapabilitiesChanged(capabilities, Collections.<Capability>emptySet());
- return () -> listener.onCapabilitiesChanged(Collections.<Capability>emptySet(), capabilities);
+ listener.onCapabilitiesChanged(capabilities, Collections.emptySet());
+ return () -> listener.onCapabilitiesChanged(Collections.emptySet(), capabilities);
}
@Override
@Override
public Set<NetconfOperation> getNetconfOperations() {
- return Sets.<NetconfOperation>newHashSet(
+ return Sets.newHashSet(
new Get(netconfSessionIdForReporting, netconfNotificationManager),
createSubscription);
}
} catch (final IOException e) {
LOG.warn("Unable to download yang library from {}", url, e);
- return new LibraryModulesSchemas(Collections.<QName, URL>emptyMap());
+ return new LibraryModulesSchemas(Collections.emptyMap());
}
}
} catch (final ExecutionException e) {
LOG.warn("{}: Unable to detect available schemas, get to {} failed", deviceId,
MODULES_STATE_MODULE_LIST, e);
- return new LibraryModulesSchemas(Collections.<QName, URL>emptyMap());
+ return new LibraryModulesSchemas(Collections.emptyMap());
}
if (moduleListNodeResult.getErrors().isEmpty() == false) {
LOG.warn("{}: Unable to detect available schemas, get to {} failed, {}",
deviceId, MODULES_STATE_MODULE_LIST, moduleListNodeResult.getErrors());
- return new LibraryModulesSchemas(Collections.<QName, URL>emptyMap());
+ return new LibraryModulesSchemas(Collections.emptyMap());
}
}
LOG.warn("{}: Unable to detect available schemas, get to {} was empty", deviceId, toId(ModulesState.QNAME));
- return new LibraryModulesSchemas(Collections.<QName, URL>emptyMap());
+ return new LibraryModulesSchemas(Collections.emptyMap());
}
private static LibraryModulesSchemas create(final ContainerNode modulesStateNode) {
} catch (final IOException e) {
LOG.warn("Unable to download yang library from {}", url, e);
- return new LibraryModulesSchemas(Collections.<QName, URL>emptyMap());
+ return new LibraryModulesSchemas(Collections.emptyMap());
}
}
contentType.equals("application/json") ? readJson(in) : readXml(in);
if (!optionalModulesStateNode.isPresent()) {
- return new LibraryModulesSchemas(Collections.<QName, URL>emptyMap());
+ return new LibraryModulesSchemas(Collections.emptyMap());
}
final NormalizedNode<?, ?> modulesStateNode = optionalModulesStateNode.get();
return new LibraryModulesSchemas(schemasMapping.build());
} catch (final IOException e) {
LOG.warn("Unable to download yang library from {}", connection.getURL(), e);
- return new LibraryModulesSchemas(Collections.<QName, URL>emptyMap());
+ return new LibraryModulesSchemas(Collections.emptyMap());
}
}
: QName.create(URI.create(moduleNameSpace), moduleName);
try {
- return Optional.<Map.Entry<QName, URL>>of(new AbstractMap.SimpleImmutableEntry<>(
+ return Optional.of(new AbstractMap.SimpleImmutableEntry<>(
moduleQName, new URL(schemaUriAsString.get())));
} catch (final MalformedURLException e) {
LOG.warn("Skipping library schema for {}. URL {} representing yang schema resource is not valid",
private static final Logger LOG = LoggerFactory.getLogger(NetconfStateSchemas.class);
- public static final NetconfStateSchemas EMPTY = new NetconfStateSchemas(Collections.<RemoteYangSchema>emptySet());
+ public static final NetconfStateSchemas EMPTY = new NetconfStateSchemas(Collections.emptySet());
private static final YangInstanceIdentifier STATE_SCHEMAS_IDENTIFIER =
YangInstanceIdentifier.builder().node(NetconfState.QNAME).node(Schemas.QNAME).build();
final RemoteDeviceId id,
final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> remoteDevice,
final int rpcMessageLimit) {
- this(id, remoteDevice, Optional.<UserPreferences>absent(), rpcMessageLimit);
+ this(id, remoteDevice, Optional.absent(), rpcMessageLimit);
}
private NetconfDeviceCommunicator(
}
final DataContainerChild<?, ?> editStructure =
- netOps.createEditConfigStrcture(Optional.<NormalizedNode<?, ?>>fromNullable(data),
+ netOps.createEditConfigStrcture(Optional.fromNullable(data),
Optional.of(ModifyAction.REPLACE), path);
- editConfig(path, Optional.fromNullable(data), editStructure, Optional.<ModifyAction>absent(), "put");
+ editConfig(path, Optional.fromNullable(data), editStructure, Optional.absent(), "put");
}
@Override
}
final DataContainerChild<?, ?> editStructure =
- netOps.createEditConfigStrcture(Optional.<NormalizedNode<?, ?>>fromNullable(data),
- Optional.<ModifyAction>absent(), path);
- editConfig(path, Optional.fromNullable(data), editStructure, Optional.<ModifyAction>absent(), "merge");
+ netOps.createEditConfigStrcture(Optional.fromNullable(data),
+ Optional.absent(), path);
+ editConfig(path, Optional.fromNullable(data), editStructure, Optional.absent(), "merge");
}
/**
public synchronized void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
checkEditable(store);
final DataContainerChild<?, ?> editStructure =
- netOps.createEditConfigStrcture(Optional.<NormalizedNode<?, ?>>absent(),
+ netOps.createEditConfigStrcture(Optional.absent(),
Optional.of(ModifyAction.DELETE), path);
- editConfig(path, Optional.<NormalizedNode<?, ?>>absent(),
+ editConfig(path, Optional.absent(),
editStructure, Optional.of(ModifyAction.NONE), "delete");
}
public ListenableFuture<DOMRpcResult> editConfigCandidate(final FutureCallback<? super DOMRpcResult> callback,
final DataContainerChild<?, ?> editStructure,
final boolean rollback) {
- return editConfig(callback, NETCONF_CANDIDATE_QNAME, editStructure, Optional.<ModifyAction>absent(), rollback);
+ return editConfig(callback, NETCONF_CANDIDATE_QNAME, editStructure, Optional.absent(), rollback);
}
public ListenableFuture<DOMRpcResult> editConfigRunning(final FutureCallback<? super DOMRpcResult> callback,
public ListenableFuture<DOMRpcResult> editConfigRunning(final FutureCallback<? super DOMRpcResult> callback,
final DataContainerChild<?, ?> editStructure,
final boolean rollback) {
- return editConfig(callback, NETCONF_RUNNING_QNAME, editStructure, Optional.<ModifyAction>absent(), rollback);
+ return editConfig(callback, NETCONF_RUNNING_QNAME, editStructure, Optional.absent(), rollback);
}
public ListenableFuture<DOMRpcResult> editConfig(
*/
package org.opendaylight.netconf.sal.connect.netconf.util;
-import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
}
private static Map<QName, DataSchemaNode> asMap(final Collection<DataSchemaNode> childNodes) {
- return Maps.uniqueIndex(childNodes, (Function<DataSchemaNode, QName>) DataSchemaNode::getQName);
+ return Maps.uniqueIndex(childNodes, DataSchemaNode::getQName);
}
@Override
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.ModuleImport;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.repo.api.MissingSchemaSourceException;
// Make fallback attempt to fail due to empty resolved sources
final SchemaResolutionException schemaResolutionException
= new SchemaResolutionException("fail first",
- Collections.<SourceIdentifier>emptyList(), HashMultimap.<SourceIdentifier, ModuleImport>create());
+ Collections.emptyList(), HashMultimap.create());
doReturn(Futures.immediateFailedFuture(schemaResolutionException))
.when(schemaFactory).createSchemaContext(anyCollectionOf(SourceIdentifier.class));
import org.opendaylight.yangtools.util.xml.UntrustedXML;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- final DOMRpcResult value = new DefaultDOMRpcResult(getNode(), Collections.<RpcError>emptySet());
+ final DOMRpcResult value = new DefaultDOMRpcResult(getNode(), Collections.emptySet());
CheckedFuture<DOMRpcResult, DOMRpcException> response = Futures.immediateCheckedFuture(value);
doReturn(response).when(service).invokeRpc(any(SchemaPath.class), any(NormalizedNode.class));
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Schemas;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.schemas.Schema;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.ModifyAction;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
-import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.w3c.dom.Element;
import org.xml.sax.SAXException;
public class NetconfMessageTransformerTest {
assertNotNull(compositeNodeRpcResult.getResult());
final DOMSource schemaContent =
((AnyXmlNode) ((ContainerNode) compositeNodeRpcResult.getResult()).getValue().iterator().next()).getValue();
- assertThat(((Element) schemaContent.getNode()).getTextContent(),
+ assertThat(schemaContent.getNode().getTextContent(),
CoreMatchers.containsString("Random YANG SCHEMA"));
}
.nodeWithKey(Schema.QNAME, keys).build();
final DataContainerChild<?, ?> editConfigStructure =
createEditConfigStructure(BaseSchema.BASE_NETCONF_CTX_WITH_NOTIFICATIONS.getSchemaContext(), id,
- Optional.<ModifyAction>absent(), Optional.<NormalizedNode<?, ?>>fromNullable(schemaNode));
+ Optional.absent(), Optional.fromNullable(schemaNode));
final DataContainerChild<?, ?> target = NetconfBaseOps.getTargetNode(NETCONF_CANDIDATE_QNAME);
@Override
public AutoCloseable registerCapabilityListener(
final CapabilityListener listener) {
- listener.onCapabilitiesChanged(caps, Collections.<Capability>emptySet());
+ listener.onCapabilitiesChanged(caps, Collections.emptySet());
return () -> {
};
}
final DiscardChanges discardChanges = new DiscardChanges(
String.valueOf(currentSessionId), transactionProvider);
- return Sets.<NetconfOperation>newHashSet(get, getConfig,
+ return Sets.newHashSet(get, getConfig,
editConfig, commit, lock, unLock, discardChanges);
}
@Override
public AutoCloseable registerCapabilityListener(
final CapabilityListener listener) {
- listener.onCapabilitiesChanged(caps, Collections.<Capability>emptySet());
+ listener.onCapabilitiesChanged(caps, Collections.emptySet());
return () -> {
};
}
@Override
public AutoCloseable registerCapabilityListener(
final CapabilityListener listener) {
- listener.onCapabilitiesChanged(caps, Collections.<Capability>emptySet());
+ listener.onCapabilitiesChanged(caps, Collections.emptySet());
return () -> {
};
}
@Override
protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
throws DocumentedException {
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
@Override
}, delayAggregator, TimeUnit.SECONDS);
}
}
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
private static NetconfMessage parseNetconfNotification(String content) {
storage.setConfigList(configElementData.getChildElements());
}
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
@Override
@Override
protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
throws DocumentedException {
- return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.<String>absent());
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
}
@Override
@Override
public Set<Object> getSingletons() {
- return Collections.<Object>singleton(this.yangLibService);
+ return Collections.singleton(this.yangLibService);
}
}
builder.withChild(childBuilder.build());
} else if (child instanceof LeafNode) {
final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
- final Object nodeVal = ((LeafNode<?>) child).getValue();
+ final Object nodeVal = child.getValue();
final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
Builders.leafBuilder((LeafSchemaNode) childSchema);
if (keys.contains(child.getNodeType())) {
- leafBuilder.withValue(((LeafNode<?>) child).getValue());
+ leafBuilder.withValue(child.getValue());
builder.withChild(leafBuilder.build());
} else {
if (trim) {
if (defaultVal == null || !defaultVal.equals(nodeVal)) {
- leafBuilder.withValue(((LeafNode<?>) child).getValue());
+ leafBuilder.withValue(child.getValue());
builder.withChild(leafBuilder.build());
}
} else {
if (defaultVal != null && defaultVal.equals(nodeVal)) {
- leafBuilder.withValue(((LeafNode<?>) child).getValue());
+ leafBuilder.withValue(child.getValue());
builder.withChild(leafBuilder.build());
}
}
builder.withChild(childBuilder.build());
} else if (child instanceof LeafNode) {
final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
- final Object nodeVal = ((LeafNode<?>) child).getValue();
+ final Object nodeVal = child.getValue();
final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
Builders.leafBuilder((LeafSchemaNode) childSchema);
if (trim) {
if (defaultVal == null || !defaultVal.equals(nodeVal)) {
- leafBuilder.withValue(((LeafNode<?>) child).getValue());
+ leafBuilder.withValue(child.getValue());
builder.withChild(leafBuilder.build());
}
} else {
if (defaultVal != null && defaultVal.equals(nodeVal)) {
- leafBuilder.withValue(((LeafNode<?>) child).getValue());
+ leafBuilder.withValue(child.getValue());
builder.withChild(leafBuilder.build());
}
}
return childByQName((Module) container, name);
} else {
throw new IllegalArgumentException("Unhandled parameter types: "
- + Arrays.<Object>asList(container, name).toString());
+ + Arrays.asList(container, name).toString());
}
}
private InstanceIdentifierContext<?> collectPathArguments(final InstanceIdentifierBuilder builder,
final List<String> strings, final DataNodeContainer parentNode, final DOMMountPoint mountPoint,
final boolean returnJustMountPoint) {
- Preconditions.<List<String>>checkNotNull(strings);
+ Preconditions.checkNotNull(strings);
if (parentNode == null) {
return null;
* Type of the event.
*/
enum EventType {
- REGISTER, DEREGISTER, NOTIFY;
+ REGISTER, DEREGISTER, NOTIFY
}
fail("Expected an exception to be thrown.");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.APPLICATION, ErrorTag.OPERATION_NOT_SUPPORTED,
- Optional.<String>absent(), Optional.<String>absent());
+ Optional.absent(), Optional.absent());
}
}
fail("Expected an exception to be thrown.");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.TRANSPORT, ErrorTag.OPERATION_FAILED, Optional.of("foo"),
- Optional.<String>absent());
+ Optional.absent());
verifyRestconfDocumentedException(e, 1, ErrorType.RPC, ErrorTag.IN_USE, Optional.of("bar"),
Optional.of("app-tag"));
}
fail("Expected an exception");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
- Optional.<String>absent(), Optional.<String>absent());
+ Optional.absent(), Optional.absent());
}
}
fail("Expected an exception");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.RPC, ErrorTag.UNKNOWN_ELEMENT,
- Optional.<String>absent(), Optional.<String>absent());
+ Optional.absent(), Optional.absent());
}
}
fail("Expected an exception.");
} catch (final RestconfDocumentedException e) {
verifyRestconfDocumentedException(e, 0, ErrorType.PROTOCOL, ErrorTag.INVALID_VALUE,
- Optional.<String>absent(), Optional.<String>absent());
+ Optional.absent(), Optional.absent());
}
}
final String uriPath = "toaster:cancel-toast";
- final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
+ final Optional<String> output = this.service.invokeRpc(uriPath, Optional.absent());
assertEquals("Output present", false, output.isPresent());
final String uriPath = "toaster:testOutput";
- final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
+ final Optional<String> output = this.service.invokeRpc(uriPath, Optional.absent());
assertEquals("Output present", true, output.isPresent());
assertNotNull("Returned null response", output.get());
final String uriPath = "toaster:cancel-toast";
- this.service.invokeRpc(uriPath, Optional.<String>absent());
+ this.service.invokeRpc(uriPath, Optional.absent());
}
void testGet(final LogicalDatastoreType datastoreType) throws OperationFailedException {
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.rest.common.TestRestconfUtils;
import org.opendaylight.netconf.sal.rest.api.Draft02;
public void createConfigurationDataNullTest() throws UnsupportedEncodingException {
when(brokerFacade.commitConfigurationDataPost(any(SchemaContext.class), any(YangInstanceIdentifier.class),
any(NormalizedNode.class), Mockito.anyString(), Mockito.anyString()))
- .thenReturn(Futures.<Void, TransactionCommitFailedException>immediateCheckedFuture(null));
+ .thenReturn(Futures.immediateCheckedFuture(null));
//FIXME : find who is set schemaContext
// final String URI_1 = "/config";
final PutResult result = Mockito.mock(PutResult.class);
final CheckedFuture<Void, TransactionCommitFailedException> checkedFuture =
Futures.immediateCheckedFuture(null);
- Mockito.when(this.brokerFacade.commitConfigurationDataPut(this.schemaContext, yii, data, null, null))
+ Mockito.when(this.brokerFacade.commitConfigurationDataPut(schemaContext, yii, data, null, null))
.thenReturn(result);
Mockito.when(result.getFutureOfPutData()).thenReturn(checkedFuture);
Mockito.when(result.getStatus()).thenReturn(Status.OK);
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.OrderedLeafSetNode;
import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
final NormalizedNode<?, ?> emptySubtree = ImmutableNodes.fromInstanceId(schemaContext, path);
writeTx.merge(datastore, YangInstanceIdentifier.create(emptySubtree.getIdentifier()), emptySubtree);
TransactionUtil.ensureParentsByMerge(path, schemaContext, writeTx);
- for (final MapEntryNode child : ((MapNode) payload).getValue()) {
+ for (final MapEntryNode child : payload.getValue()) {
final YangInstanceIdentifier childPath = path.node(child.getIdentifier());
writeTx.put(datastore, childPath, child);
}
builder.withChild(childBuilder.build());
} else if (child instanceof LeafNode) {
final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
- final Object nodeVal = ((LeafNode<?>) child).getValue();
+ final Object nodeVal = child.getValue();
final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
Builders.leafBuilder((LeafSchemaNode) childSchema);
if (keys.contains(child.getNodeType())) {
builder.withChild(childBuilder.build());
} else if (child instanceof LeafNode) {
final Object defaultVal = ((LeafSchemaNode) childSchema).getType().getDefaultValue().orElse(null);
- final Object nodeVal = ((LeafNode<?>) child).getValue();
+ final Object nodeVal = child.getValue();
final NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> leafBuilder =
Builders.leafBuilder((LeafSchemaNode) childSchema);
if (trim) {
* Type of the event.
*/
enum EventType {
- REGISTER, DEREGISTER, NOTIFY;
+ REGISTER, DEREGISTER, NOTIFY
}
final String uriPath = "toaster:cancel-toast";
- final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
+ final Optional<String> output = this.service.invokeRpc(uriPath, Optional.absent());
assertEquals("Output present", false, output.isPresent());
final String uriPath = "toaster:testOutput";
- final Optional<String> output = this.service.invokeRpc(uriPath, Optional.<String>absent());
+ final Optional<String> output = this.service.invokeRpc(uriPath, Optional.absent());
assertEquals("Output present", true, output.isPresent());
assertNotNull("Returned null response", output.get());
final String uriPath = "toaster:cancel-toast";
- this.service.invokeRpc(uriPath, Optional.<String>absent());
+ this.service.invokeRpc(uriPath, Optional.absent());
}
void testGet(final LogicalDatastoreType datastoreType) throws OperationFailedException {
assertNotNull(normNode);
final List<Object> listOfValues = new ArrayList<>();
- for (final DataContainerChild<? extends PathArgument, ?> child : ((ContainerNode) normNode).getValue()) {
+ for (final DataContainerChild<? extends PathArgument, ?> child : normNode.getValue()) {
if (child.getNodeType().equals(MonitoringModule.CONT_CAPABILITES_QNAME)) {
for (final DataContainerChild<? extends PathArgument, ?> dataContainerChild : ((ContainerNode) child)
.getValue()) {
for (final DataContainerChild<? extends PathArgument, ?> child : containerNode.getValue()) {
if (child instanceof LeafNode) {
- assertEquals(IetfYangLibrary.MODULE_SET_ID_LEAF_QNAME, ((LeafNode<?>) child).getNodeType());
+ assertEquals(IetfYangLibrary.MODULE_SET_ID_LEAF_QNAME, child.getNodeType());
}
if (child instanceof MapNode) {
- assertEquals(IetfYangLibrary.MODULE_QNAME_LIST, ((MapNode) child).getNodeType());
+ assertEquals(IetfYangLibrary.MODULE_QNAME_LIST, child.getNodeType());
for (final MapEntryNode mapEntryNode : ((MapNode) child).getValue()) {
String name = "";
String revision = "";
.getValue()) {
switch (dataContainerChild.getNodeType().getLocalName()) {
case IetfYangLibrary.SPECIFIC_MODULE_NAME_LEAF:
- name = String.valueOf(((LeafNode<?>) dataContainerChild).getValue());
+ name = String.valueOf(dataContainerChild.getValue());
break;
case IetfYangLibrary.SPECIFIC_MODULE_REVISION_LEAF:
- revision = String.valueOf(((LeafNode<?>) dataContainerChild).getValue());
+ revision = String.valueOf(dataContainerChild.getValue());
break;
default :
LOG.info("Unknown local name '{}' of node.",
LOG.debug("Adding path: [{}]", resourcePath);
api.setPath(resourcePath.concat(getContent(dataStore)));
- Iterable<DataSchemaNode> childSchemaNodes = Collections.<DataSchemaNode>emptySet();
+ Iterable<DataSchemaNode> childSchemaNodes = Collections.emptySet();
if (node instanceof ListSchemaNode || node instanceof ContainerSchemaNode) {
final DataNodeContainer dataNodeContainer = (DataNodeContainer) node;
childSchemaNodes = dataNodeContainer.getChildNodes();