public ServiceObject toServiceObject() { return new ServiceObject(ipProtocol, name, ports); } }
public ServiceObjectBean(ServiceObject serviceObject) { ipProtocol = serviceObject.getIpProtocol(); name = serviceObject.getName(); ports = serviceObject.getPorts(); }
@Test public void conversionToAndFrom() { ServiceObject serviceObject = new ServiceObject(IpProtocol.TCP, "so", new SubRange(1, 2)); ServiceObjectBean bean = new ServiceObjectBean(serviceObject); assertThat(new ServiceObjectBean(bean.toServiceObject()), 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()); } }