@Test
public void testIpProtocolExpansion() {
assertThat(expandProtocols(null), nullValue());
assertThat(expandProtocols(""), nullValue());
assertThat(expandProtocols("TCP"), contains(IpProtocol.TCP));
assertThat(expandProtocols(" TCP , UDP"), containsInAnyOrder(IpProtocol.TCP, IpProtocol.UDP));
assertThat(expandProtocols("6,17"), containsInAnyOrder(IpProtocol.TCP, IpProtocol.UDP));
assertThat(expandProtocols("6,!17"), containsInAnyOrder(IpProtocol.TCP));
assertThat(expandProtocols("TCP, !UDP"), containsInAnyOrder(IpProtocol.TCP));
assertThat(
expandProtocols("!UDP"),
equalTo(
Sets.difference(
ImmutableSet.copyOf(IpProtocol.values()), ImmutableSet.of(IpProtocol.UDP))));
}