@Test public void testTagConversion() throws Exception { assertSameContents(Sets.newHashSet("attribute"), Type.BOOLEAN.toTagSet(true, "attribute")); assertSameContents(Sets.newHashSet("noattribute"), Type.BOOLEAN.toTagSet(false, "attribute")); assertSameContents( Sets.newHashSet("whiskey"), Type.STRING.toTagSet("whiskey", "preferred_cocktail")); assertSameContents( Sets.newHashSet("cheddar", "ementaler", "gruyere"), Type.STRING_LIST.toTagSet( Lists.newArrayList("cheddar", "ementaler", "gruyere"), "cheeses")); }
@Test public void testIllegalTagConversIonFromNullOnSupportedType() throws Exception { try { Type.BOOLEAN.toTagSet(null, "a_boolean"); fail("Expect UnsuportedOperationException"); } catch (IllegalStateException e) { // Success. } }