2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Nordix Foundation.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.common.endpoints.http.server.test;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.OutputStream;
27 import java.lang.annotation.Annotation;
28 import java.lang.reflect.Type;
29 import javax.ws.rs.core.MediaType;
30 import javax.ws.rs.core.MultivaluedMap;
32 import lombok.AccessLevel;
35 import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJsonProvider;
38 * JacksonJsonProvider that tracks activities.
40 public class MyJacksonProvider extends JacksonJsonProvider {
42 @Setter(AccessLevel.PRIVATE)
43 private static boolean readSome = false;
45 @Setter(AccessLevel.PRIVATE)
46 private static boolean wroteSome = false;
49 * Constructs the object and resets the variables to indicate that no activity has
52 public MyJacksonProvider() {
57 public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
58 MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
61 return super.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
65 public void writeTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
66 MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException {
69 super.writeTo(object, type, genericType, annotations, mediaType, httpHeaders, entityStream);
72 public static boolean hasReadSome() {
76 public static boolean hasWrittenSome() {
80 public static void resetSome() {
81 MyJacksonProvider.readSome = false;
82 MyJacksonProvider.wroteSome = false;