Jordan Halterman | 9b3a7ce | 2017-08-25 15:12:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.store.service; |
| 17 | |
| 18 | import java.util.Map; |
| 19 | import java.util.concurrent.CompletableFuture; |
| 20 | |
| 21 | import org.onosproject.store.primitives.NodeUpdate; |
| 22 | import org.onosproject.store.primitives.TransactionId; |
| 23 | |
| 24 | /** |
| 25 | * Test asynchronous document tree. |
| 26 | */ |
| 27 | public class TestAsyncDocumentTree<V> implements AsyncDocumentTree<V> { |
| 28 | private final DocumentTree<V> tree; |
| 29 | |
| 30 | public TestAsyncDocumentTree(String name) { |
| 31 | this.tree = new TestDocumentTree<>(name); |
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | public String name() { |
| 36 | return tree.name(); |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | public DocumentPath root() { |
| 41 | return tree.root(); |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public CompletableFuture<Map<String, Versioned<V>>> getChildren(DocumentPath path) { |
| 46 | return CompletableFuture.completedFuture(tree.getChildren(path)); |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public CompletableFuture<Versioned<V>> get(DocumentPath path) { |
| 51 | return CompletableFuture.completedFuture(tree.get(path)); |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public CompletableFuture<Versioned<V>> set(DocumentPath path, V value) { |
| 56 | return CompletableFuture.completedFuture(tree.set(path, value)); |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public CompletableFuture<Boolean> create(DocumentPath path, V value) { |
| 61 | return CompletableFuture.completedFuture(tree.create(path, value)); |
| 62 | } |
| 63 | |
| 64 | @Override |
| 65 | public CompletableFuture<Boolean> createRecursive(DocumentPath path, V value) { |
| 66 | return CompletableFuture.completedFuture(tree.createRecursive(path, value)); |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public CompletableFuture<Boolean> replace(DocumentPath path, V newValue, long version) { |
| 71 | return CompletableFuture.completedFuture(tree.replace(path, newValue, version)); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public CompletableFuture<Boolean> replace(DocumentPath path, V newValue, V currentValue) { |
| 76 | return CompletableFuture.completedFuture(tree.replace(path, newValue, currentValue)); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public CompletableFuture<Versioned<V>> removeNode(DocumentPath path) { |
| 81 | return CompletableFuture.completedFuture(tree.removeNode(path)); |
| 82 | } |
| 83 | |
| 84 | @Override |
| 85 | public CompletableFuture<Void> addListener(DocumentPath path, DocumentTreeListener<V> listener) { |
| 86 | tree.addListener(path, listener); |
| 87 | return CompletableFuture.completedFuture(null); |
| 88 | } |
| 89 | |
| 90 | @Override |
| 91 | public CompletableFuture<Void> removeListener(DocumentTreeListener<V> listener) { |
| 92 | tree.removeListener(listener); |
| 93 | return CompletableFuture.completedFuture(null); |
| 94 | } |
| 95 | |
| 96 | @Override |
| 97 | public CompletableFuture<Version> begin(TransactionId transactionId) { |
| 98 | return null; |
| 99 | } |
| 100 | |
| 101 | @Override |
| 102 | public CompletableFuture<Boolean> prepare(TransactionLog<NodeUpdate<V>> transactionLog) { |
| 103 | return null; |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public CompletableFuture<Boolean> prepareAndCommit(TransactionLog<NodeUpdate<V>> transactionLog) { |
| 108 | return null; |
| 109 | } |
| 110 | |
| 111 | @Override |
| 112 | public CompletableFuture<Void> commit(TransactionId transactionId) { |
| 113 | return null; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public CompletableFuture<Void> rollback(TransactionId transactionId) { |
| 118 | return null; |
| 119 | } |
| 120 | |
| 121 | @Override |
| 122 | public DocumentTree<V> asDocumentTree() { |
| 123 | return tree; |
| 124 | } |
| 125 | } |