### Question:
Cake { @Override public String toString() { return String.format("id=%s topping=%s layers=%s", id, topping, layers.toString()); } Cake(); Long getId(); void setId(Long id); CakeTopping getTopping(); void setTopping(CakeTopping topping); Set<CakeLayer> getLayers(); void setLayers(Set<CakeLayer> layers); void addLayer(CakeLayer layer); @Override String toString();  }### Answer:
@Test public void testToString() { final var topping = new CakeTopping("topping", 20); topping.setId(2345L); final var layer = new CakeLayer("layer", 100); layer.setId(3456L); final var cake = new Cake(); cake.setId(1234L); cake.setTopping(topping); cake.addLayer(layer); final var expected = "id=1234 topping=id=2345 name=topping calories=20 " + "layers=[id=3456 name=layer calories=100]"; assertEquals(expected, cake.toString()); }