Madan Jampani | 2b8e189 | 2015-12-04 11:16:47 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Foundation |
Madan Jampani | 2b8e189 | 2015-12-04 11:16:47 -0800 | [diff] [blame] | 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.persistence; |
| 17 | |
| 18 | import java.util.Map; |
| 19 | |
| 20 | import org.onosproject.persistence.PersistentMapBuilder; |
| 21 | import org.onosproject.persistence.PersistentSetBuilder; |
| 22 | import org.onosproject.store.service.Serializer; |
| 23 | |
| 24 | import com.google.common.collect.Maps; |
| 25 | |
| 26 | /** |
| 27 | * PersistenceService that produces in memory maps for use in unit testing. |
| 28 | */ |
| 29 | public class TestPersistenceService extends PersistenceServiceAdapter { |
| 30 | @Override |
| 31 | public <K, V> PersistentMapBuilder<K, V> persistentMapBuilder() { |
| 32 | return new TestPersistentMapBuilder<K, V>(); |
| 33 | } |
| 34 | |
| 35 | @Override |
| 36 | public <E> PersistentSetBuilder<E> persistentSetBuilder() { |
| 37 | throw new UnsupportedOperationException(); |
| 38 | } |
| 39 | |
| 40 | private static class TestPersistentMapBuilder<K, V> implements PersistentMapBuilder<K, V> { |
| 41 | |
| 42 | @Override |
| 43 | public PersistentMapBuilder<K, V> withName(String name) { |
| 44 | return this; |
| 45 | } |
| 46 | |
| 47 | @Override |
| 48 | public PersistentMapBuilder<K, V> withSerializer(Serializer serializer) { |
| 49 | return this; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public Map<K, V> build() { |
| 54 | return Maps.newConcurrentMap(); |
| 55 | } |
| 56 | } |
| 57 | } |