diff options
author | Jim Hahn <jrh3@att.com> | 2021-02-17 16:07:33 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-02-18 07:08:43 -0500 |
commit | 4e05982e36aa66b83fa0ee44b9631412442c3969 (patch) | |
tree | bb31502de569df19f1f6d1882f7b1bd89962982f /context/context-management/src/test/java | |
parent | f0e8b6d9e32f55d464aed55c5bb79081bb16306f (diff) |
Replace GsonXxxAdapters
The GsonXxxAdapters were removed from the models Serialization classes
and replaced with type adapters from common. Modified the code to refer
to the new adapters.
Without this fix, examples-onap-vcpe will not compile. Could that be
the cause of the apex-pdp standalone issue, POLICY-3066?
Allow TypeAdapter in lieu of JsonSerializer/Deserializer adapters in
config files.
Note: examples-ona-bbs refers to the following, which were removed
several releases ago (during the actor re-write?):
- appclcm.util.Serialization$RequestAdapter & Serialization$ResponseAdapter
Issue-ID: POLICY-2905
Change-Id: Ia57e0346343614cbd4a1cffd9c8393f207284244
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'context/context-management/src/test/java')
2 files changed, 58 insertions, 3 deletions
diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperParametersTest.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperParametersTest.java index 611eb7f25..65b2ed6ff 100644 --- a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperParametersTest.java +++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/JavaSchemaHelperParametersTest.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -72,6 +73,10 @@ public class JavaSchemaHelperParametersTest { jsonPars.setAdaptorClass("org.onap.policy.apex.context.impl.schema.java.SupportJsonAdapter"); assertTrue(pars.validate().isValid()); + jsonPars.setAdaptedClass("java.lang.String"); + jsonPars.setAdaptorClass("org.onap.policy.apex.context.impl.schema.java.SupportJsonAdapter2"); + assertTrue(pars.validate().isValid()); + Map<String, JavaSchemaHelperJsonAdapterParameters> adapterMap = new LinkedHashMap<>(); pars.setJsonAdapters(adapterMap); diff --git a/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/SupportJsonAdapter2.java b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/SupportJsonAdapter2.java new file mode 100644 index 000000000..627cde4c4 --- /dev/null +++ b/context/context-management/src/test/java/org/onap/policy/apex/context/impl/schema/java/SupportJsonAdapter2.java @@ -0,0 +1,50 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP + * ================================================================================ + * Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.apex.context.impl.schema.java; + +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonToken; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +public class SupportJsonAdapter2 extends TypeAdapter<String> { + + @Override + public void write(JsonWriter out, String value) throws IOException { + if (value == null) { + out.nullValue(); + + } else { + out.value(value); + } + } + + @Override + public String read(JsonReader in) throws IOException { + if (in.peek() == JsonToken.NULL) { + in.nextNull(); + return null; + } else { + return in.nextString(); + } + } +} |