### Question:
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);  }### Answer:
@Test public void testTextualTokenTypeAdapter() { JsonObject textualTokenJson = new JsonObject(); textualTokenJson.addProperty("token", "1"); TextualToken textualToken = adapter.deserialize(textualTokenJson, TextualToken.class, null); assertEquals(textualTokenJson.get("token").getAsString(), textualToken.getToken()); }
@Test public void testTextualTokenTypeAdapterWithStatus() { JsonObject textualTokenJson = new JsonObject(); textualTokenJson.addProperty("token", "1"); textualTokenJson.addProperty("status", "ACCEPTED"); textualTokenJson.addProperty("mobilityServiceProvider", "MSP"); textualTokenJson.addProperty("visibleId", "7007"); TextualToken textualToken = adapter.deserialize(textualTokenJson, TextualToken.class, null); assertEquals(textualTokenJson.get("token").getAsString(), textualToken.getToken()); assertEquals(textualTokenJson.get("status").getAsString(), textualToken.getAuthenticationStatus().toString()); assertEquals(textualTokenJson.get("mobilityServiceProvider").getAsString(), textualToken.getMobilityServiceProvider()); assertEquals(textualTokenJson.get("visibleId").getAsString(), textualToken.getVisibleId()); }
@Test(expected = JsonParseException.class) public void testTokenAsJsonPrimitive() { JsonPrimitive jsonPrimitive = new JsonPrimitive("1"); adapter.deserialize(jsonPrimitive, TextualToken.class, null); }
@Test(expected = IllegalArgumentException.class) public void testInvalidAuthenticationStatus() { JsonObject textualTokenJson = new JsonObject(); textualTokenJson.addProperty("token", "1"); textualTokenJson.addProperty("status", "BLOCKING"); adapter.deserialize(textualTokenJson, TextualToken.class, null); }