DownloadVersion implements Comparable<DownloadVersion> { final void seal() { if (sealed) { return; } sealed = true; for (final DownloadOSFamily family : osFamilies) { family.seal(); } } DownloadVersion(final String name);  DownloadVersion(final String name, final List<DownloadOSFamily> osFamilies); final String getName(); final List<DownloadOSFamily> getOSFamilies(); DownloadOSFamily findFamily(final String name); boolean isRelease(); @Override final int hashCode(); @Override final boolean equals(final Object obj); @Override final String toString(); @Override final int compareTo(final DownloadVersion other);  }
@Test public void testSeal() { final String version = "1.2.3"; DownloadVersion testee = new DownloadVersion(version); final DownloadOSFamily linux = new DownloadOSFamily("Linux"); final DownloadOSFamily windows = new DownloadOSFamily("Windows"); testee.addOSFamily(linux); testee.seal(); try { testee.addOSFamily(windows); fail(); } catch (final IllegalStateException ex) { assertThat(ex.getMessage()).isEqualTo("The instance is sealed"); } }