X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pmproducer%2Fsrc%2Ftest%2Fjava%2Forg%2Foran%2Fpmproducer%2Ffilter%2FPmReportFilterTest.java;h=541a2bafa11141073b47817945232660e466de0a;hb=refs%2Ftags%2F1.0.0;hp=01efe47fea2f9e733c7afc9bd99f191b37cc2989;hpb=6599eca2119b68778aaacdda9639e498e2511fef;p=nonrtric%2Fplt%2Franpm.git diff --git a/pmproducer/src/test/java/org/oran/pmproducer/filter/PmReportFilterTest.java b/pmproducer/src/test/java/org/oran/pmproducer/filter/PmReportFilterTest.java index 01efe47..541a2ba 100644 --- a/pmproducer/src/test/java/org/oran/pmproducer/filter/PmReportFilterTest.java +++ b/pmproducer/src/test/java/org/oran/pmproducer/filter/PmReportFilterTest.java @@ -24,14 +24,8 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.Gson; import com.google.gson.GsonBuilder; -import com.google.protobuf.AbstractMessage.Builder; -import com.google.protobuf.Message; -import com.google.protobuf.MessageOrBuilder; -import com.google.protobuf.util.JsonFormat; -import java.io.IOException; import java.lang.invoke.MethodHandles; -import java.lang.reflect.InvocationTargetException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; @@ -45,49 +39,6 @@ import org.slf4j.LoggerFactory; class PmReportFilterTest { - public static class ProtoJsonUtil { - - /** - * Makes a Json from a given message or builder - * - * @param messageOrBuilder is the instance - * @return The string representation - * @throws IOException if any error occurs - */ - public static String toJson(MessageOrBuilder messageOrBuilder) throws IOException { - return JsonFormat.printer().print(messageOrBuilder); - } - - /** - * Makes a new instance of message based on the json and the class - * - * @param is the class type - * @param json is the json instance - * @param clazz is the class instance - * @return An instance of T based on the json values - * @throws IOException if any error occurs - */ - @SuppressWarnings({"unchecked", "rawtypes"}) - public static T fromJson(String json, Class clazz) throws IOException { - // https://stackoverflow.com/questions/27642021/calling-parsefrom-method-for-generic-protobuffer-class-in-java/33701202#33701202 - Builder builder = null; - try { - // Since we are dealing with a Message type, we can call newBuilder() - builder = (Builder) clazz.getMethod("newBuilder").invoke(null); - - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException - | NoSuchMethodException | SecurityException e) { - return null; - } - - // The instance is placed into the builder values - JsonFormat.parser().ignoringUnknownFields().merge(json, builder); - - // the instance will be from the build - return (T) builder.build(); - } - } - private final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private static Gson gson = new GsonBuilder() //