AssetGroup { public void addAsset(Asset asset) { if (_type != asset.getType()) { throw new IllegalArgumentException("Invalid asset type: " + toString() + ", " + asset); } _assets.add(asset); }  String getName(); void setName(String name); String getUrl(); void setUrl(String url); AssetType getType(); void setType(AssetType type); void addAsset(Asset asset); List<Asset> getAssets(); String getExtension(); @Override String toString();  }
@Test public void testAddAsset() throws Exception { Asset asset1 = new Asset(); asset1.setUrl("aaaa"); Asset asset2 = new Asset(); asset2.setUrl("bbb"); Asset asset3 = new Asset(); asset3.setUrl("bbb"); AssetGroup assetGroup = new AssetGroup(); assetGroup.addAsset(asset1); assetGroup.addAsset(asset2); assetGroup.addAsset(asset3); assertEquals(2, assetGroup.getAssets().size()); assertEquals(asset1, assetGroup.getAssets().get(0)); assertEquals(asset2, assetGroup.getAssets().get(1)); }