### Question:
OpeningTimeTypeAdapterDeserializer implements TypeAdapterDeserializer<OpeningTime> { @Override public OpeningTime deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) { JsonObject obj; try { obj = jsonElement.getAsJsonObject(); if (obj == null) { return null; } } catch (ClassCastException | IllegalStateException e) { throw new JsonParseException("OpeningTime must be a valid JSON object", e); } Day day = Day.fromValue(obj.getAsJsonPrimitive("day").getAsString()); String timeStartStr = obj.getAsJsonPrimitive("timeStart").getAsString(); String timeStopStr = obj.getAsJsonPrimitive("timeStop").getAsString(); TimeOfDay timeStart; TimeOfDay timeStop; Matcher start = TIME_OF_DAY.matcher(timeStartStr); Matcher stop = TIME_OF_DAY.matcher(timeStopStr); if (start.matches() && stop.matches()) { timeStart = new TimeOfDay(Integer.parseInt(start.group(HOUR_GROUP)), Integer.parseInt(start.group(MINUTES_GROUP))); timeStop = new TimeOfDay(Integer.parseInt(stop.group(HOUR_GROUP)), Integer.parseInt(stop.group(MINUTES_GROUP))); } else { throw new JsonParseException("timeStart and timeStop must be a valid 24-hour time (00:00 - 23:59)"); } return new OpeningTime(day, timeStart, timeStop); }  @Override Class<?> getAdaptedType(); @Override OpeningTime deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext);  }### Answer:
@Test(expected = JsonParseException.class) public void testOpeningTimeAsJsonPrimitive() { JsonPrimitive jsonPrimitive = new JsonPrimitive("12:00"); adapter.deserialize(jsonPrimitive, OpeningTime.class, null); }
@Test(expected = JsonParseException.class) public void testUnparsableTimeFormat() { JsonObject openingTimeJson = new JsonObject(); openingTimeJson.addProperty("day", "Monday"); openingTimeJson.addProperty("timeStart", "12.00"); openingTimeJson.addProperty("timeStop", "15.00"); adapter.deserialize(openingTimeJson, OpeningTime.class, null); }
@Test(expected = IllegalArgumentException.class) public void testInvalidDay() { JsonObject openingTimeJson = new JsonObject(); openingTimeJson.addProperty("day", 8); openingTimeJson.addProperty("timeStart", "12:00"); openingTimeJson.addProperty("timeStop", "15:00"); adapter.deserialize(openingTimeJson, OpeningTime.class, null); }