I am trying to write more test for the REST API but...

Does anyone know why we are not getting just the body when we call

gson.fromJson(get.getResponseBodyAsString(), new TypeToken<Map<String,
Object>>(){}.getType());

get.getResponseBodyAsString() returns

*{"status":"OK","message":"","body":[{"id":"2AXE167H3","name":"spark","group":"spark","properties":{"spark.cores.max":"","spark.yarn.jar":"","master":"local[*]","zep...*

and not just the body part?

the issue is that we are getting the body as an object to the Map
object which makes it hard to test the content of the response.

Any help?

BTW, I also tried :

JsonResponse<List<InterpreterSetting>> resp =
gson.fromJson(get.getResponseBodyAsString(), new
TypeToken<JsonResponse<List<InterpreterSetting>>>(){}.getType());

but getting Runtime exception

getSettings(org.apache.zeppelin.rest.ZeppelinRestApiTest)  Time
elapsed: 0.038 sec  <<< ERROR!

java.lang.RuntimeException: Unable to invoke no-args constructor for
class org.apache.zeppelin.interpreter.Interpreter. Register an
InstanceCreator with Gson for this type may fix this problem.

        at sun.misc.Unsafe.allocateInstance(Native Method)

        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

        at java.lang.reflect.Method.invoke(Method.java:497)

        at 
com.google.gson.internal.UnsafeAllocator$1.newInstance(UnsafeAllocator.java:48)

        at 
com.google.gson.internal.ConstructorConstructor$8.construct(ConstructorConstructor.java:164)

        at 
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:162)

        at 
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)

        at 
com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:81)

        at 
com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)

        at 
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)

        at 
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)

        at 
com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40)

        at 
com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:81)

        at 
com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:60)

        at 
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:93)

        at 
com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:172)

        at com.google.gson.Gson.fromJson(Gson.java:791)

        at com.google.gson.Gson.fromJson(Gson.java:757)

        at com.google.gson.Gson.fromJson(Gson.java:706)

        at 
org.apache.zeppelin.rest.ZeppelinRestApiTest.getSettings(ZeppelinRestApiTest.java:103)

Reply via email to