public ReferenceBook build() { return new ReferenceBook( _addressGroups, _filterGroups, _interfaceGroups, _name, _serviceEndpoints, _serviceObjectGroups, _serviceObjects); }
public ServiceObjectBean(ServiceObject serviceObject) { ipProtocol = serviceObject.getIpProtocol(); name = serviceObject.getName(); ports = serviceObject.getPorts(); }
public ServiceEndpointBean(ServiceEndpoint endpoint) { address = endpoint.getAddress(); name = endpoint.getName(); service = endpoint.getService(); }
@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 testGetAddressGroups() { String group1 = "group1"; String group2 = "group2"; AddressGroup addressGroup1 = new AddressGroup(null, group1); AddressGroup addressGroup2 = new AddressGroup(null, group2); ReferenceBook refBook1 = ReferenceBook.builder("book1") .setAddressGroups(ImmutableList.of(addressGroup1, addressGroup2)) .build(); ReferenceBook refBook2 = ReferenceBook.builder("book2").setAddressGroups(ImmutableList.of(addressGroup1)).build(); ReferenceBook refBook3 = ReferenceBook.builder("book3").build(); ReferenceLibrary referenceLibrary = new ReferenceLibrary(ImmutableList.of(refBook1, refBook2, refBook3)); assertThat(getAddressGroups(referenceLibrary), equalTo(ImmutableSet.of(group1, group2))); }
@Test public void testGetAddressBooks() { String book1 = "book1"; String book2 = "book2"; ReferenceBook refBook1 = ReferenceBook.builder(book1).build(); ReferenceBook refBook2 = ReferenceBook.builder(book2).build(); ReferenceLibrary referenceLibrary = new ReferenceLibrary(ImmutableList.of(refBook1, refBook2)); assertThat(getAddressBooks(referenceLibrary), equalTo(ImmutableSet.of(book1, book2))); }
/** * From the {@link ReferenceLibrary} at {@code dataPath}, get the {@link ReferenceBook} with name * {@code bookName}. * * @throws IOException If the contents of the file could not be cast to {@link ReferenceLibrary} */ public static Optional<ReferenceBook> getReferenceBook( @Nonnull Path dataPath, @Nonnull String bookName) throws IOException { ReferenceLibrary data = read(dataPath); return data.getReferenceBook(bookName); }
public AddressGroupBean(AddressGroup addressGroup) { name = addressGroup.getName(); addresses = ImmutableSet.copyOf(addressGroup.getAddresses()); }
public FilterGroupBean(FilterGroup filterGroup) { name = filterGroup.getName(); filters = ImmutableList.copyOf(filterGroup.getFilters()); }
public InterfaceGroupBean(InterfaceGroup interfaceGroup) { name = interfaceGroup.getName(); interfaces = ImmutableSet.copyOf(interfaceGroup.getInterfaces()); }
/** * Gets the {@link ReferenceLibrary} for the {@code network}. * * @throws IOException The contents of reference library file cannot be converted to {@link * ReferenceLibrary} */ public ReferenceLibrary getReferenceLibrary(String network) throws IOException { return ReferenceLibrary.read(getReferenceLibraryPath(network)); }
@Override public Optional<ReferenceBook> getReferenceBook(String bookName) { return _batfish.getReferenceLibraryData().getReferenceBook(bookName); }
public ServiceEndpoint toServiceEndpoint() { return new ServiceEndpoint(address, name, service); } }
public ServiceObject toServiceObject() { return new ServiceObject(ipProtocol, name, ports); } }
public ServiceObjectGroupBean(ServiceObjectGroup group) { name = group.getName(); services = ImmutableSet.copyOf(group.getServices()); }
public InterfaceGroup(SortedSet<NodeInterfacePair> interfaces, String name) { ReferenceLibrary.checkValidName(name, "interface group"); _name = name; _interfaces = ImmutableSortedSet.copyOf(interfaces); }
public static Builder builder(String name) { return new Builder(name); }
@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()); } }
public ServiceObject( @JsonProperty(PROP_IP_PROTOCOL) IpProtocol ipProtocol, @JsonProperty(PROP_NAME) String name, @JsonProperty(PROP_PORTS) SubRange ports) { checkArgument(ipProtocol != null, "Service object ipProtocol not be null"); checkArgument(name != null, "Service object name cannot be null"); checkArgument(ports != null, "Service object ports cannot be null"); ReferenceLibrary.checkValidName(name, "service object"); _ipProtocol = ipProtocol; _name = name; _ports = ports; }