@Test(expected = JsonParseException.class) public void testTokenAsJsonPrimitive() { JsonPrimitive jsonPrimitive = new JsonPrimitive("1"); adapter.deserialize(jsonPrimitive, TextualToken.class, null); }
@Override public TextualToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { JsonObject obj; try { obj = json.getAsJsonObject(); } catch (ClassCastException | IllegalStateException e) { throw new JsonParseException("TextualToken must be a JSON object", e); } String token = getMemberAsString(obj, TOKEN_MEMBER, ""); IdentifyingToken.AuthenticationStatus statusToSet = null; String status = getMemberAsString(obj, "status", null); if (status != null) { statusToSet = IdentifyingToken.AuthenticationStatus.valueOf(status); } String mobilityServiceProvider = getMemberAsString(obj, "mobilityServiceProvider", null); String visibleId = getMemberAsString(obj, "visibleId", null); return new TextualToken(token, statusToSet, mobilityServiceProvider, visibleId); }
TextualTokenTypeAdapterDeserializer implements TypeAdapterDeserializer<TextualToken> { @Override public TextualToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { JsonObject obj; try { obj = json.getAsJsonObject(); } catch (ClassCastException | IllegalStateException e) { throw new JsonParseException("TextualToken must be a JSON object", e); } String token = getMemberAsString(obj, TOKEN_MEMBER, ""); IdentifyingToken.AuthenticationStatus statusToSet = null; String status = getMemberAsString(obj, "status", null); if (status != null) { statusToSet = IdentifyingToken.AuthenticationStatus.valueOf(status); } String mobilityServiceProvider = getMemberAsString(obj, "mobilityServiceProvider", null); String visibleId = getMemberAsString(obj, "visibleId", null); return new TextualToken(token, statusToSet, mobilityServiceProvider, visibleId); } }
TextualTokenTypeAdapterDeserializer implements TypeAdapterDeserializer<TextualToken> { @Override public TextualToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { JsonObject obj; try { obj = json.getAsJsonObject(); } catch (ClassCastException | IllegalStateException e) { throw new JsonParseException("TextualToken must be a JSON object", e); } String token = getMemberAsString(obj, TOKEN_MEMBER, ""); IdentifyingToken.AuthenticationStatus statusToSet = null; String status = getMemberAsString(obj, "status", null); if (status != null) { statusToSet = IdentifyingToken.AuthenticationStatus.valueOf(status); } String mobilityServiceProvider = getMemberAsString(obj, "mobilityServiceProvider", null); String visibleId = getMemberAsString(obj, "visibleId", null); return new TextualToken(token, statusToSet, mobilityServiceProvider, visibleId); }  }
TextualTokenTypeAdapterDeserializer implements TypeAdapterDeserializer<TextualToken> { @Override public TextualToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { JsonObject obj; try { obj = json.getAsJsonObject(); } catch (ClassCastException | IllegalStateException e) { throw new JsonParseException("TextualToken must be a JSON object", e); } String token = getMemberAsString(obj, TOKEN_MEMBER, ""); IdentifyingToken.AuthenticationStatus statusToSet = null; String status = getMemberAsString(obj, "status", null); if (status != null) { statusToSet = IdentifyingToken.AuthenticationStatus.valueOf(status); } String mobilityServiceProvider = getMemberAsString(obj, "mobilityServiceProvider", null); String visibleId = getMemberAsString(obj, "visibleId", null); return new TextualToken(token, statusToSet, mobilityServiceProvider, visibleId); }  @Override Class<?> getAdaptedType(); @Override TextualToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context); }
TextualTokenTypeAdapterDeserializer implements TypeAdapterDeserializer<TextualToken> { @Override public TextualToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) { JsonObject obj; try { obj = json.getAsJsonObject(); } catch (ClassCastException | IllegalStateException e) { throw new JsonParseException("TextualToken must be a JSON object", e); } String token = getMemberAsString(obj, TOKEN_MEMBER, ""); IdentifyingToken.AuthenticationStatus statusToSet = null; String status = getMemberAsString(obj, "status", null); if (status != null) { statusToSet = IdentifyingToken.AuthenticationStatus.valueOf(status); } String mobilityServiceProvider = getMemberAsString(obj, "mobilityServiceProvider", null); String visibleId = getMemberAsString(obj, "visibleId", null); return new TextualToken(token, statusToSet, mobilityServiceProvider, visibleId); }  @Override Class<?> getAdaptedType(); @Override TextualToken deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context);  }