ContentTypes { public List<ContentType> getListOfContentTypes() { return Collections.unmodifiableList(contentTypes); } ContentTypes(ContentType... arrayOfContentTypes); List<ContentType> getListOfContentTypes();  }
@Test public void listShouldIncludeContentTypeArguments(){ ContentType xmlContentType = ContentType.createContentType("application/xml"); ContentType jsonContentType = ContentType.createContentType("application/json"); ContentType rssXmlContentType = ContentType.createContentType("application/rss+xml"); ContentTypes contentTypes = new ContentTypes(xmlContentType, jsonContentType, rssXmlContentType); List<ContentType> list = contentTypes.getListOfContentTypes(); assertThat(list.size(), is(3)); assertTrue(list.contains(xmlContentType)); assertTrue(list.contains(jsonContentType)); assertTrue(list.contains(rssXmlContentType)); }
@Test(expected = UnsupportedOperationException.class) public void listShouldBeunmodifiableList(){ ContentType xmlContentType = ContentType.createContentType("application/xml"); ContentType jsonContentType = ContentType.createContentType("application/json"); ContentType rssXmlContentType = ContentType.createContentType("application/rss+xml"); ContentTypes contentTypes = new ContentTypes(xmlContentType, jsonContentType, rssXmlContentType); List<ContentType> list = contentTypes.getListOfContentTypes(); list.add(xmlContentType); }