@Test void cardModelWithoutDescriptionOrContent() { CardModel cardModel = getRandomCardModel(false, 0, false); JsonObject result = CardModelAdapter.serialize(cardModel); assertThat(result.has("iconType")).isTrue(); assertThat(result.has("iconSrc")).isTrue(); assertThat(result.has("description")).isFalse(); assertThat(result.has("content")).isFalse(); }
public static JsonObject serialize(CardModel cardModel) { JsonObject result = new JsonObject(); result.addProperty("iconType", cardModel.iconType().name().toLowerCase()); result.addProperty("iconSrc", cardModel.iconSrc()); if (cardModel.description().getLeft().isPresent() || cardModel.description().getRight().isPresent()) { result.add("description", getTextAndUrl(cardModel.description())); } if (cardModel.content().size() != 0) { result.add("content", getContent(cardModel.content())); } return result; }
CardModelAdapter { public static JsonObject serialize(CardModel cardModel) { JsonObject result = new JsonObject(); result.addProperty("iconType", cardModel.iconType().name().toLowerCase()); result.addProperty("iconSrc", cardModel.iconSrc()); if (cardModel.description().getLeft().isPresent() || cardModel.description().getRight().isPresent()) { result.add("description", getTextAndUrl(cardModel.description())); } if (cardModel.content().size() != 0) { result.add("content", getContent(cardModel.content())); } return result; } }
CardModelAdapter { public static JsonObject serialize(CardModel cardModel) { JsonObject result = new JsonObject(); result.addProperty("iconType", cardModel.iconType().name().toLowerCase()); result.addProperty("iconSrc", cardModel.iconSrc()); if (cardModel.description().getLeft().isPresent() || cardModel.description().getRight().isPresent()) { result.add("description", getTextAndUrl(cardModel.description())); } if (cardModel.content().size() != 0) { result.add("content", getContent(cardModel.content())); } return result; }  }
CardModelAdapter { public static JsonObject serialize(CardModel cardModel) { JsonObject result = new JsonObject(); result.addProperty("iconType", cardModel.iconType().name().toLowerCase()); result.addProperty("iconSrc", cardModel.iconSrc()); if (cardModel.description().getLeft().isPresent() || cardModel.description().getRight().isPresent()) { result.add("description", getTextAndUrl(cardModel.description())); } if (cardModel.content().size() != 0) { result.add("content", getContent(cardModel.content())); } return result; }  static JsonObject serialize(CardModel cardModel); static JsonArray serialize(List<CardModel> cards); }
CardModelAdapter { public static JsonObject serialize(CardModel cardModel) { JsonObject result = new JsonObject(); result.addProperty("iconType", cardModel.iconType().name().toLowerCase()); result.addProperty("iconSrc", cardModel.iconSrc()); if (cardModel.description().getLeft().isPresent() || cardModel.description().getRight().isPresent()) { result.add("description", getTextAndUrl(cardModel.description())); } if (cardModel.content().size() != 0) { result.add("content", getContent(cardModel.content())); } return result; }  static JsonObject serialize(CardModel cardModel); static JsonArray serialize(List<CardModel> cards);  }