return method;
} catch (NoSuchMethodException e) {
throw new AssertionError("Method " + name + " with args " + Arrays.toString(args)
- + " does not exists in class " + clazz.getSimpleName());
+ + " does not exists in class " + clazz.getSimpleName(), e);
}
}
public abstract Set<? extends Class<? extends D>> getRequiredDelegates();
- protected abstract T createInstance(ClassToInstanceMap<D> delegates);
+ protected abstract T createInstance(ClassToInstanceMap<D> immutableDelegates);
private void checkAllRequiredServices() {
for (final Class<? extends D> type : getRequiredDelegates()) {
@Override
protected final T createInstance(final ClassToInstanceMap<DOMService> delegates) {
Preconditions.checkState(codec != null);
- return createInstance(codec,delegates);
+ return createInstance(codec, delegates);
}
- protected abstract T createInstance(BindingToNormalizedNodeCodec codec2, ClassToInstanceMap<DOMService> delegates);
+ protected abstract T createInstance(BindingToNormalizedNodeCodec myCodec, ClassToInstanceMap<DOMService> delegates);
}
private final BindingToNormalizedNodeCodec codec;
private final DOMDataTreeCommitCohortRegistry registry;
- BindingDOMDataTreeCommitCohortRegistryAdapter(BindingToNormalizedNodeCodec codec,
- DOMDataTreeCommitCohortRegistry registry) {
+ BindingDOMDataTreeCommitCohortRegistryAdapter(final BindingToNormalizedNodeCodec codec,
+ final DOMDataTreeCommitCohortRegistry registry) {
this.codec = Preconditions.checkNotNull(codec);
this.registry = Preconditions.checkNotNull(registry);
}
- DataTreeCommitCohortRegistry from(BindingToNormalizedNodeCodec codec, DOMDataTreeCommitCohortRegistry registry) {
+ static DataTreeCommitCohortRegistry from(final BindingToNormalizedNodeCodec codec,
+ final DOMDataTreeCommitCohortRegistry registry) {
return new BindingDOMDataTreeCommitCohortRegistryAdapter(codec, registry);
}
@Override
public <D extends DataObject, T extends DataTreeCommitCohort<D>> ObjectRegistration<T> registerCommitCohort(
- DataTreeIdentifier<D> subtree, final T cohort) {
+ final DataTreeIdentifier<D> subtree, final T cohort) {
final BindingDOMDataTreeCommitCohortAdapter<D> adapter =
new BindingDOMDataTreeCommitCohortAdapter<>(codec, cohort);
final DOMDataTreeIdentifier domPath = codec.toDOMDataTreeIdentifier(subtree);
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
final RpcInvocationStrategy rpc = rpcNames.get(method);
}
private ListenableFuture<RpcResult<?>> transformFuture(final SchemaPath rpc,
- final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeCodecRegistry codec) {
+ final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeCodecRegistry resultCodec) {
return Futures.transform(domFuture, (Function<DOMRpcResult, RpcResult<?>>) input -> {
final NormalizedNode<?, ?> domData = input.getResult();
final DataObject bindingResult;
if (domData != null) {
final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(), "output"));
- bindingResult = codec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData);
+ bindingResult = resultCodec.fromNormalizedNodeRpcData(rpcOutput, (ContainerNode) domData);
} else {
bindingResult = null;
}
private NormalizedNode<?, ?> normalizedNode;
@Before
- public void basicTest() throws Exception {
+ public void basicTest() {
final BindingBrokerTestFactory testFactory = new BindingBrokerTestFactory();
testFactory.setExecutor(Executors.newCachedThreadPool());
}
@Test
- public void toBindingTestWithMap() throws Exception {
- final NormalizedNode<?, ?> normalizedNode = mock(NormalizedNode.class);
- assertNotNull(forwardedDataBroker.toBinding(BA_TREE_LEAF_ONLY, ImmutableMap.of(data, normalizedNode)));
+ public void toBindingTestWithMap() {
+ final NormalizedNode<?, ?> mockNode = mock(NormalizedNode.class);
+ assertNotNull(forwardedDataBroker.toBinding(BA_TREE_LEAF_ONLY, ImmutableMap.of(data, mockNode)));
}
@Test
- public void toBindingTestWithSet() throws Exception {
+ public void toBindingTestWithSet() {
assertNotNull(forwardedDataBroker.toBinding(BA_TREE_LEAF_ONLY, ImmutableSet.of(data)));
}
@Test
- public void toBindingDataTest() throws Exception {
+ public void toBindingDataTest() {
assertNotNull(forwardedDataBroker.toBindingData(BA_TOP_LEVEL_LIST, normalizedNode));
}
- private class AbstractForwardedDataBrokerImpl extends AbstractForwardedDataBroker {
+ private static final class AbstractForwardedDataBrokerImpl extends AbstractForwardedDataBroker {
- private AbstractForwardedDataBrokerImpl(final DOMDataBroker domDataBroker,
+ AbstractForwardedDataBrokerImpl(final DOMDataBroker domDataBroker,
final BindingToNormalizedNodeCodec codec) {
super(domDataBroker, codec);
}
private SchemaContext context;
@Override
- protected void setupWithSchema(final SchemaContext context) {
- this.context = context;
+ protected void setupWithSchema(final SchemaContext schemaContext) {
+ this.context = schemaContext;
final DataObjectSerializerGenerator streamWriter = StreamWriterGenerator.create(JavassistUtils.forClassPool(
ClassPool.getDefault()));
final BindingNormalizedNodeCodecRegistry registry = new BindingNormalizedNodeCodecRegistry(streamWriter);
assertNotNull(lazyDOMRpcResultFuture.get());
}
- @SuppressWarnings({"checkstyle:IllegalThrows","checkstyle:IllegalCatch"})
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch", "checkstyle:avoidHidingCauseException"})
@Test(expected = InterruptedException.class)
public void checkedGetWithException() throws Throwable {
doThrow(InterruptedException.class).when(future).get();
}
}
- @SuppressWarnings({"checkstyle:IllegalThrows","checkstyle:IllegalCatch"})
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch", "checkstyle:avoidHidingCauseException"})
@Test(expected = InterruptedException.class)
public void checkedGetWithException2() throws Throwable {
doThrow(InterruptedException.class).when(future).get(1, TimeUnit.SECONDS);
private DataBroker dataBroker;
private DOMDataBroker domBroker;
-
@Override
protected void setupWithSchema(final SchemaContext context) {
testCustomizer = createDataBrokerTestCustomizer();
setupWithDataBroker(dataBroker);
}
- protected void setupWithDataBroker(final DataBroker dataBroker) {
+ protected void setupWithDataBroker(final DataBroker broker) {
// Intentionally left No-op, subclasses may customize it
}
throw new IllegalStateException(e);
}
}
-
-
}
private static final class EventCapturingListener<T extends DataObject> implements DataTreeChangeListener<T> {
- private SettableFuture<Collection<DataTreeModification<T>>> changes = SettableFuture.create();
+ private SettableFuture<Collection<DataTreeModification<T>>> futureChanges = SettableFuture.create();
@Override
public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
- this.changes.set(changes);
+ this.futureChanges.set(changes);
}
Collection<DataTreeModification<T>> nextEvent() throws Exception {
- final Collection<DataTreeModification<T>> result = changes.get(200,TimeUnit.MILLISECONDS);
- changes = SettableFuture.create();
+ final Collection<DataTreeModification<T>> result = futureChanges.get(200,TimeUnit.MILLISECONDS);
+ futureChanges = SettableFuture.create();
return result;
}
-
}
@Override
return new BindingToNormalizedStreamWriter(schema, delegate);
}
- private void emitSchema(final Object schema) {
- delegate.nextDataSchemaNode((DataSchemaNode) schema);
+ private void emitSchema(final Object schemaNode) {
+ delegate.nextDataSchemaNode((DataSchemaNode) schemaNode);
}
NodeCodecContext<?> current() {
proxyConstructor = MethodHandles.publicLookup().findConstructor(proxyClass, CONSTRUCTOR_TYPE)
.asType(DATAOBJECT_TYPE);
} catch (NoSuchMethodException | IllegalAccessException e) {
- throw new IllegalStateException("Failed to find contructor for class " + proxyClass);
+ throw new IllegalStateException("Failed to find contructor for class " + proxyClass, e);
}
}
try {
ctor = MethodHandles.publicLookup().unreflectConstructor(getConstructor(keyClass));
} catch (IllegalAccessException e) {
- throw new IllegalArgumentException("Missing construct in class " + keyClass);
+ throw new IllegalArgumentException("Missing constructor in class " + keyClass, e);
}
final MethodHandle inv = MethodHandles.spreadInvoker(ctor.type(), 0);
this.ctorInvoker = inv.asType(inv.type().changeReturnType(Identifier.class));
* <p>
* By serialization / deserialization of this exception {@link #getBindingClass()} will return null.
*/
-public class MissingSchemaForClassException extends MissingSchemaException {
+public final class MissingSchemaForClassException extends MissingSchemaException {
private static final long serialVersionUID = 1L;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class ChoiceDispatchSerializer implements DataObjectSerializerImplementation {
+public final class ChoiceDispatchSerializer implements DataObjectSerializerImplementation {
private static final Logger LOG = LoggerFactory.getLogger(ChoiceDispatchSerializer.class);
this.choiceClass = Preconditions.checkNotNull(choiceClass);
}
- public static final ChoiceDispatchSerializer from(final Class<? extends DataContainer> choiceClass) {
+ public static ChoiceDispatchSerializer from(final Class<? extends DataContainer> choiceClass) {
return new ChoiceDispatchSerializer(choiceClass);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsal.test.binding.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class ExampleYangObjects {
+public final class ExampleYangObjects {
+ private ExampleYangObjects() {
+
+ }
public static AbstractMap.SimpleImmutableEntry<InstanceIdentifier<Top>, Top> topEmpty() {
return new SimpleImmutableEntry<>(InstanceIdentifier.create(Top.class), new TopBuilder().build());
* @see AssertDataObjects
* @see AssertDataObjectsTest
*/
-public class ExpectedObjects {
+public final class ExpectedObjects {
+
+ private ExpectedObjects() {
+
+ }
public static TopLevelList topLevelList() {
TopLevelListBuilder it = new TopLevelListBuilder();
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class BindingReflections {
+public final class BindingReflections {
private static final long EXPIRATION_TIME = 60;
* QName, but QName with correct namespace revision, but virtual local name, since augmentations do not
* have name. May return null if QName is not present.
*/
- public static final QName findQName(final Class<?> dataType) {
+ public static QName findQName(final Class<?> dataType) {
return CLASS_TO_QNAME.getUnchecked(dataType).orNull();
}
}
@SuppressWarnings("checkstyle:illegalCatch")
- public static final QNameModule getQNameModule(final Class<?> clz) {
+ public static QNameModule getQNameModule(final Class<?> clz) {
if (DataContainer.class.isAssignableFrom(clz) || BaseIdentity.class.isAssignableFrom(clz)) {
return findQName(clz).getModule();
}
}
}
- public static final QNameModule getQNameModule(final YangModuleInfo modInfo) {
+ public static QNameModule getQNameModule(final YangModuleInfo modInfo) {
return QNameModule.create(URI.create(modInfo.getNamespace()), QName.parseRevision(modInfo.getRevision()));
}
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
-public class DataObjectReadingUtil {
+public final class DataObjectReadingUtil {
private static final DataObjectReadingStrategy REAUSABLE_AUGMENTATION_READING_STRATEGY =
new AugmentationReadingStrategy();
* Path, which is nested to parent, and should be read.
* @return Value of object.
*/
- public static final <T extends DataObject, P extends DataObject> Map<InstanceIdentifier<T>, T> readData(
+ public static <T extends DataObject, P extends DataObject> Map<InstanceIdentifier<T>, T> readData(
final P parent, final InstanceIdentifier<P> parentPath, final InstanceIdentifier<T> childPath) {
checkArgument(parent != null, "Parent must not be null.");
checkArgument(parentPath != null, "Parent path must not be null");
return readData(entry.getValue(), entry.getKey(), pathArgument);
}
- public static final <T extends DataObject> Optional<T> readData(final DataObject source, final Class<T> child) {
+ public static <T extends DataObject> Optional<T> readData(final DataObject source, final Class<T> child) {
checkArgument(source != null, "Object should not be null.");
checkArgument(child != null, "Child type should not be null");
Class<? extends DataContainer> parentClass = source.getImplementedInterface();
public abstract Map<InstanceIdentifier, DataContainer> readUsingPathArgument(DataContainer parent,
PathArgument childArgument, InstanceIdentifier targetBuilder);
- public abstract DataContainer read(DataContainer parent, Class<?> childType);
+ public abstract DataContainer read(DataContainer parent, Class<?> child);
private static Method resolveGetterMethod(final Class<? extends DataContainer> parent, final Class<?> child) {
String methodName = "get" + child.getSimpleName();
}
@SuppressWarnings("rawtypes")
- private static class ContainerReadingStrategy extends DataObjectReadingStrategy {
+ private static final class ContainerReadingStrategy extends DataObjectReadingStrategy {
ContainerReadingStrategy(final Class<? extends DataContainer> parent,
final Class<? extends DataContainer> child) {
super(parent, child);
}
@Override
- public DataContainer read(final DataContainer parent, final Class<?> childType) {
+ public DataContainer read(final DataContainer parent, final Class<?> child) {
try {
Object potentialData = getGetterMethod().invoke(parent);
checkState(potentialData instanceof DataContainer);
}
@SuppressWarnings("rawtypes")
- private static class ListItemReadingStrategy extends DataObjectReadingStrategy {
+ private static final class ListItemReadingStrategy extends DataObjectReadingStrategy {
ListItemReadingStrategy(final Class<? extends DataContainer> parent, final Class child) {
super(parent, child);
checkArgument(Iterable.class.isAssignableFrom(getGetterMethod().getReturnType()));
}
@Override
- public DataContainer read(final DataContainer parent, final Class<?> childType) {
+ public DataContainer read(final DataContainer parent, final Class<?> child) {
// This will always fail since we do not have key.
return null;
}
}
@Override
- public DataContainer read(final DataContainer parent, final Class<?> childType) {
- checkArgument(Augmentation.class.isAssignableFrom(childType), "Parent must be Augmentable.");
+ public DataContainer read(final DataContainer parent, final Class<?> child) {
+ checkArgument(Augmentation.class.isAssignableFrom(child), "Child must be Augmentation.");
checkArgument(parent instanceof Augmentable<?>, "Parent must be Augmentable.");
@SuppressWarnings({ "rawtypes", "unchecked" })
- Augmentation potential = ((Augmentable) parent).getAugmentation(childType);
+ Augmentation potential = ((Augmentable) parent).getAugmentation(child);
checkState(potential instanceof DataContainer, "Readed augmention must be data object");
return (DataContainer) potential;
}
}
@Test(expected = UnsupportedOperationException.class)
- @SuppressWarnings("checkstyle:illegalThrows")
+ @SuppressWarnings({ "checkstyle:illegalThrows", "checkstyle:avoidHidingCauseException" })
public void privateConstructTest() throws Throwable {
final Constructor<BindingMapping> bindingMappingConstructor = BindingMapping.class.getDeclaredConstructor();
assertFalse(bindingMappingConstructor.isAccessible());
}
@Test(expected = UnsupportedOperationException.class)
- @SuppressWarnings("checkstyle:illegalThrows")
+ @SuppressWarnings({ "checkstyle:illegalThrows", "checkstyle:avoidHidingCauseException" })
public void testPrivateConstructor() throws Throwable {
assertFalse(BindingReflections.class.getDeclaredConstructor().isAccessible());
final Constructor<?> constructor = BindingReflections.class.getDeclaredConstructor();
}
@Test(expected = UnsupportedOperationException.class)
- @SuppressWarnings("checkstyle:illegalThrows")
+ @SuppressWarnings({ "checkstyle:illegalThrows", "checkstyle:avoidHidingCauseException" })
public void testPrivateConstructor() throws Throwable {
assertFalse(DataObjectReadingUtil.class.getDeclaredConstructor().isAccessible());
final Constructor<?> constructor = DataObjectReadingUtil.class.getDeclaredConstructor();
}
@Test(expected = IllegalStateException.class)
- @SuppressWarnings("checkstyle:illegalThrows")
+ @SuppressWarnings({ "checkstyle:illegalThrows", "checkstyle:avoidHidingCauseException" })
public void fromWithExceptionTest() throws Throwable {
try {
NotificationListenerInvoker.from(TestPrivateInterface.class);
* Data tree commit cohort registry adapter.
*/
@Beta
-public class BindingDOMDataTreeCommitCohortRegistryAdapter implements DataTreeCommitCohortRegistry {
+public final class BindingDOMDataTreeCommitCohortRegistryAdapter implements DataTreeCommitCohortRegistry {
private final BindingToNormalizedNodeCodec codec;
private final DOMDataTreeCommitCohortRegistry registry;
* Producer adapter.
*/
@Beta
-public class BindingDOMDataTreeProducerAdapter implements DataTreeProducer {
+public final class BindingDOMDataTreeProducerAdapter implements DataTreeProducer {
private final DOMDataTreeProducer delegate;
private final BindingToNormalizedNodeCodec codec;
*
*/
@Beta
-public class BindingDOMDataTreeServiceAdapter implements DataTreeService {
+public final class BindingDOMDataTreeServiceAdapter implements DataTreeService {
private final DOMDataTreeService delegate;
private final BindingToNormalizedNodeCodec codec;
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
final RpcInvocationStrategy rpc = rpcNames.get(method);
}
private ListenableFuture<RpcResult<?>> transformFuture(final SchemaPath rpc,
- final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeCodecRegistry codec) {
+ final ListenableFuture<DOMRpcResult> domFuture, final BindingNormalizedNodeCodecRegistry resultCodec) {
return Futures.transform(domFuture, (Function<DOMRpcResult, RpcResult<?>>) input -> {
final NormalizedNode<?, ?> domData = input.getResult();
final TreeNode bindingResult;
if (domData != null) {
final SchemaPath rpcOutput = rpc.createChild(QName.create(rpc.getLastComponent(), "output"));
- bindingResult = codec.fromNormalizedNodeOperationData(rpcOutput, (ContainerNode) domData);
+ bindingResult = resultCodec.fromNormalizedNodeOperationData(rpcOutput, (ContainerNode) domData);
} else {
bindingResult = null;
}
private final ClassToInstanceMap<D> delegates = MutableClassToInstanceMap.create();
- protected abstract T createInstance(ClassToInstanceMap<D> delegates);
+ protected abstract T createInstance(ClassToInstanceMap<D> immutableDelegates);
/**
* Get required delegates.
private BindingToNormalizedNodeCodec codec;
- protected abstract T createInstance(BindingToNormalizedNodeCodec codec, ClassToInstanceMap<DOMService> delegates);
+ protected abstract T createInstance(BindingToNormalizedNodeCodec myCodec, ClassToInstanceMap<DOMService> delegates);
@Override
protected final T createInstance(final ClassToInstanceMap<DOMService> delegates) {
setupWithDataBroker(dataBroker);
}
- protected void setupWithDataBroker(final DataBroker dataBroker) {
+ protected void setupWithDataBroker(final DataBroker broker) {
// Intentionally left No-op, subclasses may customize it
}
* properties of parent codec and stateless implementations are used (
* {@link ChoiceDispatchSerializer}, {@link AugmentableDispatchSerializer},
* which uses registry to dispatch to concrete item codec.
- *
*/
@Beta
-public class StreamWriterGenerator extends AbstractStreamWriterGenerator {
+public final class StreamWriterGenerator extends AbstractStreamWriterGenerator {
private static final String UNKNOWN_SIZE = BindingStreamEventWriter.class.getName() + ".UNKNOWN_SIZE";
try {
ctor = MethodHandles.publicLookup().unreflectConstructor(getConstructor(keyClass));
} catch (final IllegalAccessException e) {
- throw new IllegalArgumentException("Missing construct in class " + keyClass);
+ throw new IllegalArgumentException("Missing construct in class " + keyClass, e);
}
final MethodHandle inv = MethodHandles.spreadInvoker(ctor.type(), 0);
this.ctorInvoker = inv.asType(inv.type().changeReturnType(Identifier.class));
* will return null.
*/
@Beta
-public class MissingSchemaForClassException extends MissingSchemaException {
+public final class MissingSchemaForClassException extends MissingSchemaException {
private static final long serialVersionUID = 1L;
proxyConstructor = MethodHandles.publicLookup().findConstructor(proxyClass, CONSTRUCTOR_TYPE)
.asType(TREENODE_TYPE);
} catch (NoSuchMethodException | IllegalAccessException e) {
- throw new IllegalStateException("Failed to find contructor for class " + proxyClass);
+ throw new IllegalStateException("Failed to find contructor for class " + proxyClass, e);
}
}
return new BindingToNormalizedStreamWriter(schema, delegate);
}
- private void emitSchema(final Object schema) {
- delegate.nextDataSchemaNode((DataSchemaNode) schema);
+ private void emitSchema(final Object schemaNode) {
+ delegate.nextDataSchemaNode((DataSchemaNode) schemaNode);
}
/**
* Dispatch serializer, which emit DOM data from Binding v2 via stream writer.
*/
@Beta
-public class ChoiceDispatchSerializer implements TreeNodeSerializerImplementation {
+public final class ChoiceDispatchSerializer implements TreeNodeSerializerImplementation {
private static final Logger LOG = LoggerFactory.getLogger(ChoiceDispatchSerializer.class);
* - class choice
* @return instance of serializer
*/
- public static final ChoiceDispatchSerializer from(final Class<? extends Instantiable<?>> choiceClass) {
+ public static ChoiceDispatchSerializer from(final Class<? extends Instantiable<?>> choiceClass) {
return new ChoiceDispatchSerializer(choiceClass);
}
*
*/
@Beta
-public class LazyDataTreeModification<T extends TreeNode> implements DataTreeModification<T> {
+public final class LazyDataTreeModification<T extends TreeNode> implements DataTreeModification<T> {
private final DataTreeIdentifier<T> path;
private final TreeNodeModification<T> rootNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
abstract class AbstractDOMRpcRoutingTableEntry {
- private final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> impls;
+ private final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> implementations;
private final SchemaPath schemaPath;
AbstractDOMRpcRoutingTableEntry(final SchemaPath schemaPath, final Map<YangInstanceIdentifier,
- List<DOMRpcImplementation>> impls) {
+ List<DOMRpcImplementation>> implementations) {
this.schemaPath = Preconditions.checkNotNull(schemaPath);
- this.impls = Preconditions.checkNotNull(impls);
+ this.implementations = Preconditions.checkNotNull(implementations);
}
final SchemaPath getSchemaPath() {
}
final List<DOMRpcImplementation> getImplementations(final YangInstanceIdentifier context) {
- return impls.get(context);
+ return implementations.get(context);
}
final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> getImplementations() {
- return impls;
+ return implementations;
}
final boolean containsContext(final YangInstanceIdentifier contextReference) {
- return impls.containsKey(contextReference);
+ return implementations.containsKey(contextReference);
}
final Set<YangInstanceIdentifier> registeredIdentifiers(final DOMRpcAvailabilityListener listener) {
- return Maps.filterValues(impls, list -> list.stream().anyMatch(listener::acceptsImplementation)).keySet();
+ return Maps.filterValues(implementations, list -> list.stream()
+ .anyMatch(listener::acceptsImplementation)).keySet();
}
@VisibleForTesting
final Set<YangInstanceIdentifier> registeredIdentifiers() {
- return impls.keySet();
+ return implementations.keySet();
}
/**
final AbstractDOMRpcRoutingTableEntry add(
final DOMRpcImplementation implementation, final List<YangInstanceIdentifier> newRpcs) {
final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
- for (final Entry<YangInstanceIdentifier, List<DOMRpcImplementation>> ve : impls.entrySet()) {
+ for (final Entry<YangInstanceIdentifier, List<DOMRpcImplementation>> ve : implementations.entrySet()) {
if (newRpcs.remove(ve.getKey())) {
final List<DOMRpcImplementation> i = new ArrayList<>(ve.getValue().size() + 1);
i.addAll(ve.getValue());
final AbstractDOMRpcRoutingTableEntry remove(
final DOMRpcImplementation implementation, final List<YangInstanceIdentifier> removed) {
final Builder<YangInstanceIdentifier, List<DOMRpcImplementation>> vb = ImmutableMap.builder();
- for (final Entry<YangInstanceIdentifier, List<DOMRpcImplementation>> ve : impls.entrySet()) {
+ for (final Entry<YangInstanceIdentifier, List<DOMRpcImplementation>> ve : implementations.entrySet()) {
if (removed.remove(ve.getKey())) {
final List<DOMRpcImplementation> i = new ArrayList<>(ve.getValue());
i.remove(implementation);
* so they do have mutable state.
*/
final class DOMNotificationRouterEvent {
- public static final EventFactory<DOMNotificationRouterEvent> FACTORY =
- new EventFactory<DOMNotificationRouterEvent>() {
- @Override
- public DOMNotificationRouterEvent newInstance() {
- return new DOMNotificationRouterEvent();
- }
- };
+ static final EventFactory<DOMNotificationRouterEvent> FACTORY = DOMNotificationRouterEvent::new;
private Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers;
private DOMNotification notification;
// Hidden on purpose, initialized in initialize()
}
+ @SuppressWarnings("checkstyle:hiddenField")
ListenableFuture<Void> initialize(final DOMNotification notification,
final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers) {
this.notification = Preconditions.checkNotNull(notification);
return ret;
}
- DOMRpcRoutingTable add(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcs) {
- if (rpcs.isEmpty()) {
+ DOMRpcRoutingTable add(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcsToAdd) {
+ if (rpcsToAdd.isEmpty()) {
return this;
}
// First decompose the identifiers to a multimap
- final ListMultimap<SchemaPath, YangInstanceIdentifier> toAdd = decomposeIdentifiers(rpcs);
+ final ListMultimap<SchemaPath, YangInstanceIdentifier> toAdd = decomposeIdentifiers(rpcsToAdd);
// Now iterate over existing entries, modifying them as appropriate...
final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> mb = ImmutableMap.builder();
return new DOMRpcRoutingTable(mb.build(), schemaContext);
}
- DOMRpcRoutingTable remove(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcs) {
- if (rpcs.isEmpty()) {
+ DOMRpcRoutingTable remove(final DOMRpcImplementation implementation, final Set<DOMRpcIdentifier> rpcIds) {
+ if (rpcIds.isEmpty()) {
return this;
}
// First decompose the identifiers to a multimap
- final ListMultimap<SchemaPath, YangInstanceIdentifier> toRemove = decomposeIdentifiers(rpcs);
+ final ListMultimap<SchemaPath, YangInstanceIdentifier> toRemove = decomposeIdentifiers(rpcIds);
// Now iterate over existing entries, modifying them as appropriate...
final Builder<SchemaPath, AbstractDOMRpcRoutingTableEntry> b = ImmutableMap.builder();
return new ProducerLayout(shardMap, idToProducer, cb.build());
}
- ProducerLayout reshard(final Map<DOMDataTreeIdentifier, DOMDataTreeShard> shardMap) {
- return new ProducerLayout(shardMap, mapIdsToProducer(shardMap), children);
+ ProducerLayout reshard(final Map<DOMDataTreeIdentifier, DOMDataTreeShard> newShardMap) {
+ return new ProducerLayout(newShardMap, mapIdsToProducer(newShardMap), children);
}
boolean haveSubtree(final DOMDataTreeIdentifier subtree) {
return createProducer(subtrees, shardMap);
}
- @SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:hiddenField" })
@Override
public synchronized <T extends DOMDataTreeListener> ListenerRegistration<T> registerListener(final T listener,
final Collection<DOMDataTreeIdentifier> subtrees, final boolean allowRxMerges,
private volatile DOMDataTreeListener attachedListener;
private volatile ProducerLayout layout;
- private ShardedDOMDataTreeProducer(final ShardedDOMDataTree dataTree,
+ ShardedDOMDataTreeProducer(final ShardedDOMDataTree dataTree,
final Collection<DOMDataTreeIdentifier> subtrees,
final Map<DOMDataTreeIdentifier, DOMDataTreeShard> shardMap) {
this.dataTree = Preconditions.checkNotNull(dataTree);
}
@Override
+ @SuppressWarnings("checkstyle:hiddenField")
public DOMDataTreeProducer createProducer(final Collection<DOMDataTreeIdentifier> subtrees) {
checkNotClosed();
checkIdle();
final BiConsumer<ShardedDOMDataTreeWriteTransaction, Throwable> failure) {
LOG.debug("Readying tx {}", identifier);
- final ListenableFuture<?> future;
+ final ListenableFuture<?> internalFuture;
switch (transactions.size()) {
case 0:
success.accept(this);
case 1: {
final DOMDataTreeShardWriteTransaction tx = transactions.values().iterator().next();
tx.ready();
- future = tx.submit();
+ internalFuture = tx.submit();
break;
}
default:
- future = Futures.allAsList(transactions.values().stream().map(tx -> {
+ internalFuture = Futures.allAsList(transactions.values().stream().map(tx -> {
tx.ready();
return tx.submit();
}).collect(Collectors.toList()));
}
- Futures.addCallback(future, new FutureCallback<Object>() {
+ Futures.addCallback(internalFuture, new FutureCallback<Object>() {
@Override
public void onSuccess(final Object result) {
success.accept(ShardedDOMDataTreeWriteTransaction.this);
}
private class DelegatingCursor implements DOMDataTreeWriteCursor {
- private final Deque<PathArgument> path = new ArrayDeque<>();
+ private final Deque<PathArgument> currentArgs = new ArrayDeque<>();
private final DOMDataTreeWriteCursor delegate;
private final DOMDataTreeIdentifier rootPosition;
DelegatingCursor(final DOMDataTreeWriteCursor delegate, final DOMDataTreeIdentifier rootPosition) {
this.delegate = Preconditions.checkNotNull(delegate);
this.rootPosition = Preconditions.checkNotNull(rootPosition);
- path.addAll(rootPosition.getRootIdentifier().getPathArguments());
+ currentArgs.addAll(rootPosition.getRootIdentifier().getPathArguments());
}
@Override
public void enter(@Nonnull final PathArgument child) {
checkAvailable(child);
delegate.enter(child);
- path.push(child);
+ currentArgs.push(child);
}
@Override
@Override
public void exit() {
delegate.exit();
- path.pop();
+ currentArgs.pop();
}
@Override
public void exit(final int depth) {
delegate.exit(depth);
for (int i = 0; i < depth; i++) {
- path.pop();
+ currentArgs.pop();
}
}
@Override
public void close() {
- int depthEntered = path.size() - rootPosition.getRootIdentifier().getPathArguments().size();
+ int depthEntered = currentArgs.size() - rootPosition.getRootIdentifier().getPathArguments().size();
if (depthEntered > 0) {
// clean up existing modification cursor in case this tx will be reused for batching
delegate.exit(depthEntered);
}
void checkAvailable(final PathArgument child) {
- layout.checkAvailable(path, child);
+ layout.checkAvailable(currentArgs, child);
}
}
domForwardedCompositeTransaction.closeSubtransactions();
}
- private static class DOMForwardedCompositeTransactionTestImpl
+ private static final class DOMForwardedCompositeTransactionTestImpl
extends AbstractDOMForwardedCompositeTransaction<String, DOMStoreTransaction> {
- private DOMForwardedCompositeTransactionTestImpl(final Object identifier,
- final Map<String, DOMStoreTransaction> backingTxs) {
+ DOMForwardedCompositeTransactionTestImpl(final Object identifier,
+ final Map<String, DOMStoreTransaction> backingTxs) {
super(identifier, backingTxs);
}
}
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
-class MockingUtilities {
+final class MockingUtilities {
private MockingUtilities() {
throw new UnsupportedOperationException("Utility class");
final DOMMountPointListener listener = mock(DOMMountPointListener.class);
doNothing().when(listener).onMountPointCreated(PATH);
doNothing().when(listener).onMountPointRemoved(PATH);
- final DOMMountPointServiceImpl mountService = new DOMMountPointServiceImpl();
- mountService.registerProvisionListener(listener);
- mountService.createMountPoint(PATH).register();
+ final DOMMountPointServiceImpl service = new DOMMountPointServiceImpl();
+ service.registerProvisionListener(listener);
+ service.createMountPoint(PATH).register();
- assertTrue(mountService.getMountPoint(PATH).isPresent());
+ assertTrue(service.getMountPoint(PATH).isPresent());
- mountService.unregisterMountPoint(PATH);
+ service.unregisterMountPoint(PATH);
- assertFalse(mountService.getMountPoint(PATH).isPresent());
+ assertFalse(service.getMountPoint(PATH).isPresent());
}
@Test
schemaService.getSessionContext();
}
- private void addYangs(final ScanningSchemaServiceProvider schemaService) {
- final List<Registration> registerAvailableYangs = schemaService.registerAvailableYangs(yangs);
+ private void addYangs(final ScanningSchemaServiceProvider service) {
+ final List<Registration> registerAvailableYangs = service.registerAvailableYangs(yangs);
assertTrue(!registerAvailableYangs.isEmpty());
}
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class TestModel {
+public final class TestModel {
public static final QName TEST_QNAME =
QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
YangInstanceIdentifier.builder(ANOTHER_SHARD_PATH).node(NEW_SHARD_LIST).build();
private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
+ private TestModel() {
+ throw new UnsupportedOperationException();
+ }
+
public static SchemaContext createTestContext() throws ReactorException {
return YangParserTestUtils.parseYangStreams(Collections.singletonList(getInputStream()));
}
* @author Thomas Pantelis
* @see InMemoryDOMDataStoreFactory
*/
-public class InMemoryDOMDataStoreConfigProperties {
+public final class InMemoryDOMDataStoreConfigProperties {
public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_QUEUE_SIZE = 1000;
public static final int DEFAULT_MAX_DATA_CHANGE_EXECUTOR_POOL_SIZE = 20;
private final int maxDataChangeListenerQueueSize;
private final int maxDataStoreExecutorQueueSize;
- private InMemoryDOMDataStoreConfigProperties(int maxDataChangeExecutorPoolSize, int maxDataChangeExecutorQueueSize,
- int maxDataChangeListenerQueueSize, int maxDataStoreExecutorQueueSize) {
+ private InMemoryDOMDataStoreConfigProperties(final int maxDataChangeExecutorPoolSize,
+ final int maxDataChangeExecutorQueueSize, final int maxDataChangeListenerQueueSize,
+ final int maxDataStoreExecutorQueueSize) {
this.maxDataChangeExecutorQueueSize = maxDataChangeExecutorQueueSize;
this.maxDataChangeExecutorPoolSize = maxDataChangeExecutorPoolSize;
this.maxDataChangeListenerQueueSize = maxDataChangeListenerQueueSize;
* @param maxDataStoreExecutorQueueSize
* maximum queue size for the data store executor.
*/
- public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize,
- int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize,
- int maxDataStoreExecutorQueueSize) {
+ public static InMemoryDOMDataStoreConfigProperties create(final int maxDataChangeExecutorPoolSize,
+ final int maxDataChangeExecutorQueueSize, final int maxDataChangeListenerQueueSize,
+ final int maxDataStoreExecutorQueueSize) {
return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize,
maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize,
maxDataStoreExecutorQueueSize);
}
- public static InMemoryDOMDataStoreConfigProperties create(int maxDataChangeExecutorPoolSize,
- int maxDataChangeExecutorQueueSize, int maxDataChangeListenerQueueSize) {
+ public static InMemoryDOMDataStoreConfigProperties create(final int maxDataChangeExecutorPoolSize,
+ final int maxDataChangeExecutorQueueSize, final int maxDataChangeListenerQueueSize) {
return new InMemoryDOMDataStoreConfigProperties(maxDataChangeExecutorPoolSize,
maxDataChangeExecutorQueueSize, maxDataChangeListenerQueueSize,
DEFAULT_MAX_DATA_STORE_EXECUTOR_QUEUE_SIZE);
private final DOMDataTreeIdentifier prefix;
private final DataTree dataTree;
- private InMemoryDOMDataTreeShard(final DOMDataTreeIdentifier prefix, final Executor dataTreeChangeExecutor,
- final int maxDataChangeListenerQueueSize, final int submitQueueSize) {
+ InMemoryDOMDataTreeShard(final DOMDataTreeIdentifier prefix, final Executor dataTreeChangeExecutor,
+ final int maxDataChangeListenerQueueSize, final int submitQueueSize) {
this.prefix = Preconditions.checkNotNull(prefix);
final TreeType treeType = treeTypeFor(prefix.getDatastoreType());
}
@Override
- public void onChildAttached(final DOMDataTreeIdentifier prefix, final DOMDataTreeShard child) {
+ public void onChildAttached(final DOMDataTreeIdentifier childPrefix, final DOMDataTreeShard child) {
Preconditions.checkArgument(child != this, "Attempted to attach child %s onto self", this);
- reparentChildShards(prefix, child);
+ reparentChildShards(childPrefix, child);
- final ChildShardContext context = createContextFor(prefix, child);
- childShards.put(prefix, context);
- childShardsTable.store(prefix, context);
+ final ChildShardContext context = createContextFor(childPrefix, child);
+ childShards.put(childPrefix, context);
+ childShardsTable.store(childPrefix, context);
updateProducers();
}
@Override
- public void onChildDetached(final DOMDataTreeIdentifier prefix, final DOMDataTreeShard child) {
- childShards.remove(prefix);
- childShardsTable.remove(prefix);
+ public void onChildDetached(final DOMDataTreeIdentifier childPrefix, final DOMDataTreeShard child) {
+ childShards.remove(childPrefix);
+ childShardsTable.remove(childPrefix);
updateProducers();
}
private enum SimpleCursorOperation {
MERGE {
@Override
- void applyOnLeaf(final DOMDataTreeWriteCursor cursor, final PathArgument child,
+ void applyOnLeaf(final DOMDataTreeWriteCursor cur, final PathArgument child,
final NormalizedNode<?, ?> data) {
- cursor.merge(child, data);
+ cur.merge(child, data);
}
},
DELETE {
@Override
- void applyOnLeaf(final DOMDataTreeWriteCursor cursor, final PathArgument child,
+ void applyOnLeaf(final DOMDataTreeWriteCursor cur, final PathArgument child,
final NormalizedNode<?, ?> data) {
- cursor.delete(child);
+ cur.delete(child);
}
},
WRITE {
@Override
- void applyOnLeaf(final DOMDataTreeWriteCursor cursor, final PathArgument child,
+ void applyOnLeaf(final DOMDataTreeWriteCursor cur, final PathArgument child,
final NormalizedNode<?, ?> data) {
- cursor.write(child, data);
+ cur.write(child, data);
}
};
- abstract void applyOnLeaf(DOMDataTreeWriteCursor cursor, PathArgument child, NormalizedNode<?, ?> data);
+ abstract void applyOnLeaf(DOMDataTreeWriteCursor cur, PathArgument child, NormalizedNode<?, ?> data);
- void apply(final DOMDataTreeWriteCursor cursor, final YangInstanceIdentifier path,
+ void apply(final DOMDataTreeWriteCursor cur, final YangInstanceIdentifier path,
final NormalizedNode<?, ?> data) {
int enterCount = 0;
final Iterator<PathArgument> it = path.getPathArguments().iterator();
while (true) {
final PathArgument currentArg = it.next();
if (!it.hasNext()) {
- applyOnLeaf(cursor, currentArg, data);
+ applyOnLeaf(cur, currentArg, data);
break;
}
// We need to enter one level deeper, we are not at leaf (modified) node
- cursor.enter(currentArg);
+ cur.enter(currentArg);
enterCount++;
}
}
- cursor.exit(enterCount);
+ cur.exit(enterCount);
}
}
doReadAndThrowEx(readTx);
}
- @SuppressWarnings("checkstyle:IllegalThrows")
+ @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
private static void doReadAndThrowEx(final DOMStoreReadTransaction readTx) throws Throwable {
try {
readTx.read(TestModel.TEST_PATH).get();
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
-public class TestModel {
+public final class TestModel {
public static final QName TEST_QNAME =
QName.create("urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:store:test", "2014-03-13", "test");
YangInstanceIdentifier.builder(TEST_PATH).node(OUTER_LIST_QNAME).build();
private static final String DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
+ private TestModel() {
+ throw new UnsupportedOperationException();
+ }
+
public static SchemaContext createTestContext() throws IOException, YangSyntaxErrorException, ReactorException {
return YangParserTestUtils.parseYangStreams(Collections.singletonList(getInputStream()));
}
import static org.mockito.Mockito.verify;
import java.lang.reflect.Field;
+import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.mdsal.common.api.OptimisticLockFailedException;
public void setUp() throws Exception {
reset(IN_MEMORY_DOM_DATA_STORE);
DataTreeSnapshot dataTreeSnapshot = mock(DataTreeSnapshot.class);
- TransactionReadyPrototype transactionReadyPrototype = mock(TransactionReadyPrototype.class);
+ TransactionReadyPrototype<String> transactionReadyPrototype = mock(TransactionReadyPrototype.class);
DataTreeModification dataTreeModification = mock(DataTreeModification.class);
doReturn(dataTreeModification).when(dataTreeSnapshot).newModification();
doReturn("testModification").when(dataTreeModification).toString();
verify(IN_MEMORY_DOM_DATA_STORE).validate(any());
}
- @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
+ @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = OptimisticLockFailedException.class)
public void canCommitTestWithOptimisticLockFailedException() throws Throwable {
doThrow(new ConflictingModificationAppliedException(YangInstanceIdentifier.EMPTY, "testException"))
try {
inMemoryDOMStoreThreePhaseCommitCohort.canCommit().get();
fail("Expected exception");
- } catch (Exception e) {
+ } catch (ExecutionException e) {
assertTrue(e.getCause() instanceof OptimisticLockFailedException);
throw e.getCause();
}
}
- @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
+ @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = TransactionCommitFailedException.class)
public void canCommitTestWithTransactionCommitFailedException() throws Throwable {
doThrow(new DataValidationFailedException(YangInstanceIdentifier.EMPTY, "testException"))
try {
inMemoryDOMStoreThreePhaseCommitCohort.canCommit().get();
fail("Expected exception");
- } catch (Exception e) {
+ } catch (ExecutionException e) {
assertTrue(e.getCause() instanceof TransactionCommitFailedException);
throw e.getCause();
}
}
- @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
+ @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = UnsupportedOperationException.class)
public void canCommitTestWithUnknownException() throws Throwable {
doThrow(new UnsupportedOperationException("testException"))
try {
inMemoryDOMStoreThreePhaseCommitCohort.canCommit().get();
fail("Expected exception");
- } catch (Exception e) {
+ } catch (ExecutionException e) {
assertTrue(e.getCause() instanceof UnsupportedOperationException);
throw e.getCause();
}
verify(IN_MEMORY_DOM_DATA_STORE).prepare(any());
}
- @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
+ @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = UnsupportedOperationException.class)
public void preCommitTestWithUnknownException() throws Throwable {
doThrow(new UnsupportedOperationException("testException"))
try {
inMemoryDOMStoreThreePhaseCommitCohort.preCommit().get();
fail("Expected exception");
- } catch (Exception e) {
+ } catch (ExecutionException e) {
assertTrue(e.getCause() instanceof UnsupportedOperationException);
throw e.getCause();
}
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-public class SimpleDOMMountPoint implements DOMMountPoint {
+public final class SimpleDOMMountPoint implements DOMMountPoint {
private final YangInstanceIdentifier identifier;
private final ClassToInstanceMap<DOMService> services;
this.schemaContext = ctx;
}
- public static final SimpleDOMMountPoint create(final YangInstanceIdentifier identifier,
+ public static SimpleDOMMountPoint create(final YangInstanceIdentifier identifier,
final ClassToInstanceMap<DOMService> services, final SchemaContext ctx) {
return new SimpleDOMMountPoint(identifier, services, ctx);
}
@Override
protected void append(final State state) {
if (state instanceof Changes) {
- final Changes changes = (Changes) state;
- this.changes.addAll(changes.changes);
- subtrees = ImmutableMap.copyOf(changes.subtrees);
+ final Changes changesState = (Changes) state;
+ this.changes.addAll(changesState.changes);
+ subtrees = ImmutableMap.copyOf(changesState.subtrees);
} else if (state instanceof Failure) {
causes.addAll(((Failure) state).causes);
} else {
protected synchronized void appendInitial(final State state) {
// TODO: we could index and compress state changes here
if (state instanceof Changes) {
- final Changes changes = (Changes) state;
- this.changes.addAll(changes.changes);
- subtrees = ImmutableMap.copyOf(changes.subtrees);
+ final Changes changesState = (Changes) state;
+ this.changes.addAll(changesState.changes);
+ subtrees = ImmutableMap.copyOf(changesState.subtrees);
} else if (state instanceof Failure) {
causes.addAll(((Failure) state).causes);
} else {
private final ForeignShardModificationContext boundary;
- private WriteableSubshardBoundaryNode(final ForeignShardModificationContext boundary) {
+ WriteableSubshardBoundaryNode(final ForeignShardModificationContext boundary) {
this.boundary = Preconditions.checkNotNull(boundary);
}
TestUtils.resetMocks();
}
- private class WriteableNodeWithSubshardImpl extends WriteableNodeWithSubshard {
+ private static final class WriteableNodeWithSubshardImpl extends WriteableNodeWithSubshard {
- private WriteableNodeWithSubshardImpl(Map<PathArgument, WriteableModificationNode> children) {
+ WriteableNodeWithSubshardImpl(final Map<PathArgument, WriteableModificationNode> children) {
super(children);
}
@Override
- public WriteCursorStrategy createOperation(DOMDataTreeWriteCursor parentCursor) {
+ public WriteCursorStrategy createOperation(final DOMDataTreeWriteCursor parentCursor) {
return null;
}
assertNull(stableSnapshot);
}
- @SuppressWarnings("checkstyle:IllegalThrows")
+ @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = ReadFailedException.class)
public void readTestWithException() throws Throwable {
snapshotBackedReadTransaction.close();
}
}
- @SuppressWarnings("checkstyle:IllegalThrows")
+ @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = ReadFailedException.class)
public void readNodeTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_SNAPSHOT).readNode(any());
}
}
- @SuppressWarnings("checkstyle:IllegalThrows")
+ @SuppressWarnings({ "checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = ReadFailedException.class)
public void existsTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_SNAPSHOT).readNode(any());
import static org.mockito.Mockito.mock;
import com.google.common.base.Optional;
+import java.util.concurrent.ExecutionException;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.mdsal.common.api.ReadFailedException;
assertEquals(optional, snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.EMPTY).get());
}
- @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException" })
@Test(expected = ReadFailedException.class)
public void readTestWithNullException() throws Throwable {
doReturn(null).when(DATA_TREE_MODIFICATION).readNode(YangInstanceIdentifier.EMPTY);
try {
snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.EMPTY).get();
fail("Expected ReadFailedException");
- } catch (Exception e) {
+ } catch (ExecutionException e) {
throw e.getCause();
}
}
- @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException"})
@Test(expected = ReadFailedException.class)
public void readNodeTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_MODIFICATION).readNode(any());
try {
snapshotBackedReadWriteTransaction.read(YangInstanceIdentifier.EMPTY).get();
fail("Expected ReadFailedException");
- } catch (Exception e) {
+ } catch (ExecutionException e) {
throw e.getCause();
}
}
- @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:avoidHidingCauseException"})
@Test(expected = ReadFailedException.class)
public void existsTestWithException() throws Throwable {
doThrow(new NullPointerException("no Node")).when(DATA_TREE_MODIFICATION).readNode(any());
try {
snapshotBackedReadWriteTransaction.exists(YangInstanceIdentifier.EMPTY).get();
fail("Expected ReadFailedException");
- } catch (Exception e) {
+ } catch (ExecutionException e) {
throw e.getCause();
}
}
new Object(), false, dataTreeSnapshot, transactionReadyPrototype));
}
- @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch"})
+ @SuppressWarnings({"checkstyle:IllegalThrows", "checkstyle:IllegalCatch", "checkstyle:avoidHidingCauseException" })
@Test(expected = UnsupportedOperationException.class)
public void constructorTest() throws Throwable {
Constructor<SnapshotBackedTransactions> constructor = SnapshotBackedTransactions.class.getDeclaredConstructor();
@Test
public void readyTest() throws Exception {
- SnapshotBackedWriteTransaction<Object> snapshotBackedWriteTransaction =
- new SnapshotBackedWriteTransaction<>(
- new Object(), false, DATA_TREE_SNAPSHOT, TRANSACTION_READY_PROTOTYPE);
- Assert.assertNotNull(snapshotBackedWriteTransaction.ready());
+ SnapshotBackedWriteTransaction<Object> tx = new SnapshotBackedWriteTransaction<>(new Object(), false,
+ DATA_TREE_SNAPSHOT, TRANSACTION_READY_PROTOTYPE);
+ Assert.assertNotNull(tx.ready());
verify(TRANSACTION_READY_PROTOTYPE).transactionReady(any(), any());
- snapshotBackedWriteTransaction.close();
+ tx.close();
}
@Test(expected = IllegalArgumentException.class)