2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.common.endpoints.http.server.test;
23 import java.io.IOException;
24 import java.io.InputStream;
25 import java.io.OutputStream;
26 import java.lang.annotation.Annotation;
27 import java.lang.reflect.Type;
28 import javax.ws.rs.core.MediaType;
29 import javax.ws.rs.core.MultivaluedMap;
30 import org.onap.policy.common.endpoints.http.server.internal.GsonMessageBodyHandler;
33 * GsonMessageBodyHandler that tracks activities.
35 public class MyGsonProvider extends GsonMessageBodyHandler {
36 private static boolean readSome = false;
37 private static boolean wroteSome = false;
40 * Constructs the object and resets the variables to indicate that no activity has
43 public MyGsonProvider() {
48 public Object readFrom(Class<Object> type, Type genericType, Annotation[] annotations, MediaType mediaType,
49 MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException {
52 return super.readFrom(type, genericType, annotations, mediaType, httpHeaders, entityStream);
56 public void writeTo(Object object, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
57 MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException {
60 super.writeTo(object, type, genericType, annotations, mediaType, httpHeaders, entityStream);
63 public static boolean hasReadSome() {
67 public static boolean hasWrittenSome() {
71 public static void resetSome() {
72 MyGsonProvider.readSome = false;
73 MyGsonProvider.wroteSome = false;