@Test public void testAddLayer() { final Cake cake = new Cake(); assertNotNull(cake.getLayers()); assertTrue(cake.getLayers().isEmpty()); final Set<CakeLayer> initialLayers = new HashSet<>(); initialLayers.add(new CakeLayer("layer1", 1000)); initialLayers.add(new CakeLayer("layer2", 2000)); cake.setLayers(initialLayers); assertEquals(initialLayers, cake.getLayers()); final CakeLayer newLayer = new CakeLayer("layer3", 3000); cake.addLayer(newLayer); final Set<CakeLayer> expectedLayers = new HashSet<>(); expectedLayers.addAll(initialLayers); expectedLayers.addAll(initialLayers); expectedLayers.add(newLayer); assertEquals(expectedLayers, cake.getLayers()); }
public void addLayer(CakeLayer layer) { this.layers.add(layer); }
Cake { public void addLayer(CakeLayer layer) { this.layers.add(layer); } }
Cake { public void addLayer(CakeLayer layer) { this.layers.add(layer); } Cake(); }
Cake { public void addLayer(CakeLayer layer) { this.layers.add(layer); } Cake(); Long getId(); void setId(Long id); CakeTopping getTopping(); void setTopping(CakeTopping topping); Set<CakeLayer> getLayers(); final void setLayers(Set<CakeLayer> layers); void addLayer(CakeLayer layer); @Override String toString(); }
Cake { public void addLayer(CakeLayer layer) { this.layers.add(layer); } Cake(); Long getId(); void setId(Long id); CakeTopping getTopping(); void setTopping(CakeTopping topping); Set<CakeLayer> getLayers(); final void setLayers(Set<CakeLayer> layers); void addLayer(CakeLayer layer); @Override String toString();  }