@Test public void testToHeaderspace() { String addressBookEntryName = "addressBookEntry"; AddressBook globalAddressBook = new AddressBook("addressBook", null); globalAddressBook .getEntries() .put( addressBookEntryName, new AddressAddressBookEntry(addressBookEntryName, IpWildcard.parse("1.1.1.0/24"))); Warnings w = new Warnings(); FwFromDestinationAddressBookEntry from = new FwFromDestinationAddressBookEntry(null, globalAddressBook, addressBookEntryName); HeaderSpace headerSpace = from.toHeaderspace(w); assertThat( headerSpace, equalTo( HeaderSpace.builder() .setDstIps(new IpSpaceReference("addressBook~addressBookEntry")) .build())); }
@VisibleForTesting HeaderSpace toHeaderspace(Warnings w) { AddressBook addressBook = _zone == null ? _globalAddressBook : _zone.getAddressBook(); String addressBookName = addressBook.getAddressBookName(_addressBookEntryName); IpSpace referencedIpSpace; if (addressBookName == null) { w.redFlag( String.format("Missing destination address-book entry '%s'", _addressBookEntryName)); referencedIpSpace = EmptyIpSpace.INSTANCE; } else { String ipSpaceName = addressBookName + "~" + _addressBookEntryName; referencedIpSpace = new IpSpaceReference(ipSpaceName); } return HeaderSpace.builder().setDstIps(referencedIpSpace).build(); }
FwFromDestinationAddressBookEntry implements FwFrom { @VisibleForTesting HeaderSpace toHeaderspace(Warnings w) { AddressBook addressBook = _zone == null ? _globalAddressBook : _zone.getAddressBook(); String addressBookName = addressBook.getAddressBookName(_addressBookEntryName); IpSpace referencedIpSpace; if (addressBookName == null) { w.redFlag( String.format("Missing destination address-book entry '%s'", _addressBookEntryName)); referencedIpSpace = EmptyIpSpace.INSTANCE; } else { String ipSpaceName = addressBookName + "~" + _addressBookEntryName; referencedIpSpace = new IpSpaceReference(ipSpaceName); } return HeaderSpace.builder().setDstIps(referencedIpSpace).build(); } }
FwFromDestinationAddressBookEntry implements FwFrom { @VisibleForTesting HeaderSpace toHeaderspace(Warnings w) { AddressBook addressBook = _zone == null ? _globalAddressBook : _zone.getAddressBook(); String addressBookName = addressBook.getAddressBookName(_addressBookEntryName); IpSpace referencedIpSpace; if (addressBookName == null) { w.redFlag( String.format("Missing destination address-book entry '%s'", _addressBookEntryName)); referencedIpSpace = EmptyIpSpace.INSTANCE; } else { String ipSpaceName = addressBookName + "~" + _addressBookEntryName; referencedIpSpace = new IpSpaceReference(ipSpaceName); } return HeaderSpace.builder().setDstIps(referencedIpSpace).build(); } FwFromDestinationAddressBookEntry(
      Zone zone, AddressBook globalAddressBook, String addressBookEntryName); }
FwFromDestinationAddressBookEntry implements FwFrom { @VisibleForTesting HeaderSpace toHeaderspace(Warnings w) { AddressBook addressBook = _zone == null ? _globalAddressBook : _zone.getAddressBook(); String addressBookName = addressBook.getAddressBookName(_addressBookEntryName); IpSpace referencedIpSpace; if (addressBookName == null) { w.redFlag( String.format("Missing destination address-book entry '%s'", _addressBookEntryName)); referencedIpSpace = EmptyIpSpace.INSTANCE; } else { String ipSpaceName = addressBookName + "~" + _addressBookEntryName; referencedIpSpace = new IpSpaceReference(ipSpaceName); } return HeaderSpace.builder().setDstIps(referencedIpSpace).build(); } FwFromDestinationAddressBookEntry(
      Zone zone, AddressBook globalAddressBook, String addressBookEntryName); @Override Field getField(); @Override AclLineMatchExpr toAclLineMatchExpr(JuniperConfiguration jc, Configuration c, Warnings w); }
FwFromDestinationAddressBookEntry implements FwFrom { @VisibleForTesting HeaderSpace toHeaderspace(Warnings w) { AddressBook addressBook = _zone == null ? _globalAddressBook : _zone.getAddressBook(); String addressBookName = addressBook.getAddressBookName(_addressBookEntryName); IpSpace referencedIpSpace; if (addressBookName == null) { w.redFlag( String.format("Missing destination address-book entry '%s'", _addressBookEntryName)); referencedIpSpace = EmptyIpSpace.INSTANCE; } else { String ipSpaceName = addressBookName + "~" + _addressBookEntryName; referencedIpSpace = new IpSpaceReference(ipSpaceName); } return HeaderSpace.builder().setDstIps(referencedIpSpace).build(); } FwFromDestinationAddressBookEntry(
      Zone zone, AddressBook globalAddressBook, String addressBookEntryName); @Override Field getField(); @Override AclLineMatchExpr toAclLineMatchExpr(JuniperConfiguration jc, Configuration c, Warnings w);  }