blob: 0f169b00471e33f71c382555028b16e05a7477e4 [file] [log] [blame]
SureshBRbf35c222015-11-05 12:35:01 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
SureshBRbf35c222015-11-05 12:35:01 +05303 *
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.vtnweb.web;
17
SureshBRbf35c222015-11-05 12:35:01 +053018import org.onosproject.codec.CodecContext;
Phaneendra Manda119469d2015-12-03 15:42:37 +053019import org.onosproject.codec.CodecService;
SureshBRbf35c222015-11-05 12:35:01 +053020import org.onosproject.codec.JsonCodec;
Phaneendra Manda119469d2015-12-03 15:42:37 +053021import org.onosproject.codec.impl.CodecManager;
SureshBRbf35c222015-11-05 12:35:01 +053022
23import com.fasterxml.jackson.databind.ObjectMapper;
24
25/**
26 * Mock codec context for use in codec unit tests.
27 */
28public class SfcCodecContext implements CodecContext {
29
30 private final ObjectMapper mapper = new ObjectMapper();
Phaneendra Manda119469d2015-12-03 15:42:37 +053031 private final CodecManager codecManager = new CodecManager();
32 private final VtnCodecRegistrator manager = new VtnCodecRegistrator();
SureshBRbf35c222015-11-05 12:35:01 +053033
34 /**
35 * Constructs a new mock codec context.
36 */
37 public SfcCodecContext() {
Phaneendra Manda119469d2015-12-03 15:42:37 +053038 codecManager.activate();
39 manager.codecService = codecManager;
40 manager.activate();
SureshBRbf35c222015-11-05 12:35:01 +053041 }
42
43 @Override
44 public ObjectMapper mapper() {
45 return mapper;
46 }
47
48 @SuppressWarnings("unchecked")
49 @Override
50 public <T> T getService(Class<T> serviceClass) {
51 // TODO
52 return null;
53 }
54
SureshBRbf35c222015-11-05 12:35:01 +053055 @Override
56 public <T> JsonCodec<T> codec(Class<T> entityClass) {
Phaneendra Manda119469d2015-12-03 15:42:37 +053057 return codecManager.getCodec(entityClass);
58 }
59
60 /**
61 * Get the codec manager.
62 *
63 * @return instance of codec manager
64 */
65 public CodecService codecManager() {
66 return codecManager;
SureshBRbf35c222015-11-05 12:35:01 +053067 }
68}