Cake { public final void setLayers(Set<CakeLayer> layers) { this.layers = layers; } 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();  }
@Test public void testSetLayers() { final Cake cake = new Cake(); assertNotNull(cake.getLayers()); assertTrue(cake.getLayers().isEmpty()); final Set<CakeLayer> expectedLayers = new HashSet<>(); expectedLayers.add(new CakeLayer("layer1", 1000)); expectedLayers.add(new CakeLayer("layer2", 2000)); expectedLayers.add(new CakeLayer("layer3", 3000)); cake.setLayers(expectedLayers); assertEquals(expectedLayers, cake.getLayers()); }