public FilterGroup toFilterGroup() { return new FilterGroup(ImmutableList.copyOf(firstNonNull(filters, ImmutableSet.of())), name); } }
@Test public void conversionToAndFrom() { FilterGroup group = new FilterGroup( ImmutableList.of(new FiltersSpecifier("abc"), new FiltersSpecifier("ipv4:def")), "fg1"); FilterGroupBean bean = new FilterGroupBean(group); assertThat(new FilterGroupBean(bean.toFilterGroup()), equalTo(bean)); } }
@Test public void constructorNonEmptyBook() { ReferenceBook book2 = ReferenceBook.builder("book2") .setAddressGroups(ImmutableList.of(new AddressGroup(ImmutableSortedSet.of(), "ag1"))) .setFilterGroups(ImmutableList.of(new FilterGroup(ImmutableList.of(), "fg1"))) .setInterfaceGroups( ImmutableList.of(new InterfaceGroup(ImmutableSortedSet.of(), "ig1"))) .setServiceEndpoints(ImmutableList.of(new ServiceEndpoint("ag1", "se1", "so1"))) .setServiceObjectGroups( ImmutableList.of(new ServiceObjectGroup("sog1", ImmutableSortedSet.of()))) .setServiceObjects( ImmutableList.of(new ServiceObject(IpProtocol.TCP, "so1", new SubRange(2, 3)))) .build(); beanBookMatch(new ReferenceBookBean(book2), book2); }
@Test public void toAddressBook() { ReferenceBookBean bean = new ReferenceBookBean( ReferenceBook.builder("book2") .setAddressGroups( ImmutableList.of(new AddressGroup(ImmutableSortedSet.of(), "ag1"))) .setFilterGroups(ImmutableList.of(new FilterGroup(ImmutableList.of(), "fg1"))) .setInterfaceGroups( ImmutableList.of(new InterfaceGroup(ImmutableSortedSet.of(), "ig1"))) .setServiceEndpoints(ImmutableList.of(new ServiceEndpoint("ag1", "se1", "so1"))) .setServiceObjectGroups( ImmutableList.of(new ServiceObjectGroup("sog1", ImmutableSortedSet.of()))) .setServiceObjects( ImmutableList.of(new ServiceObject(IpProtocol.TCP, "so1", new SubRange(2, 3)))) .build()); beanBookMatch(bean, bean.toAddressBook()); } }