blob: f54f5232c00d740a4791c74bf6070283e852af0f [file] [log] [blame]
Ray Milkeyd03eda02015-01-09 14:58:48 -08001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
16package org.onosproject.codec.impl;
17
18import org.onosproject.codec.CodecContext;
19import org.onosproject.codec.JsonCodec;
20
21import com.fasterxml.jackson.databind.ObjectMapper;
22
23/**
24 * Mock codec context for use in codec unit tests.
25 */
26public final class MockCodecContext implements CodecContext {
27
28 private ObjectMapper mapper = new ObjectMapper();
29 private CodecManager manager = new CodecManager();
30
31 public MockCodecContext() {
32 manager.activate();
33 }
34
35 @Override
36 public ObjectMapper mapper() {
37 return mapper;
38 }
39
40 @Override
41 @SuppressWarnings("unchecked")
42 public <T> JsonCodec<T> codec(Class<T> entityClass) {
43 return manager.getCodec(entityClass);
44 }
45
46 @Override
47 public <T> T get(Class<T> serviceClass) {
48 return null;
49 }
50
51}