Tabnine Logo
ReferenceBook$Builder
Code IndexAdd Tabnine to your IDE (free)

How to use
ReferenceBook$Builder
in
org.batfish.referencelibrary

Best Java code snippets using org.batfish.referencelibrary.ReferenceBook$Builder (Showing top 14 results out of 315)

origin: batfish/batfish

.setAddressGroups(
  firstNonNull(addressGroups, Collections.<AddressGroupBean>emptySet()).stream()
    .map(agb -> agb.toAddressGroup())
    .collect(Collectors.toList()))
.setFilterGroups(
  firstNonNull(filterGroups, Collections.<FilterGroupBean>emptySet()).stream()
    .map(fgb -> fgb.toFilterGroup())
    .collect(Collectors.toList()))
.setInterfaceGroups(
  firstNonNull(interfaceGroups, Collections.<InterfaceGroupBean>emptySet()).stream()
    .map(igb -> igb.toInterfaceGroup())
    .collect(Collectors.toList()))
.setServiceEndpoints(
  firstNonNull(serviceEndpoints, Collections.<ServiceEndpointBean>emptySet()).stream()
    .map(seb -> seb.toServiceEndpoint())
    .collect(Collectors.toList()))
.setServiceObjectGroups(
  firstNonNull(serviceObjectGroups, Collections.<ServiceObjectGroupBean>emptySet())
    .stream()
    .map(sogb -> sogb.toServiceObjectGroup())
    .collect(Collectors.toList()))
.setServiceObjects(
  firstNonNull(serviceObjects, Collections.<ServiceObjectBean>emptySet()).stream()
    .map(seb -> seb.toServiceObject())
    .collect(Collectors.toList()))
.build();
origin: batfish/batfish

.setInterfaceGroups(
  ImmutableList.of(
    new InterfaceGroup(
        new NodeInterfacePair(node1.getHostname(), iface11.getName())),
      "group")))
.build();
origin: batfish/batfish

  new ReferenceLibrary(
    ImmutableList.of(
      ReferenceBook.builder("book1").build(), ReferenceBook.builder("book2").build()));
ReferenceLibrary.write(library, tempPath);
  ImmutableSortedSet.of(
    ReferenceBook.builder("book1")
      .setAddressGroups(
        ImmutableList.of(new AddressGroup(ImmutableSortedSet.of(), "add1")))
      .build(),
    ReferenceBook.builder("book3").build());
    ImmutableSortedSet.of(
      ReferenceBook.builder("book1")
        .setAddressGroups(
          ImmutableList.of(new AddressGroup(ImmutableSortedSet.of(), "add1")))
        .build(),
      ReferenceBook.builder("book2").build(),
      ReferenceBook.builder("book3").build())));
origin: batfish/batfish

 @Test
 public void resolve() {
  ReferenceBook book =
    ReferenceBook.builder("book1")
      .setAddressGroups(
        ImmutableList.of(
          new AddressGroup(
            ImmutableSortedSet.of("1.1.1.1", "2.2.2.2:0.0.0.8"), "group1")))
      .build();
  MockSpecifierContext ctxt =
    MockSpecifierContext.builder().setReferenceBooks(ImmutableSortedSet.of(book)).build();

  ReferenceAddressGroupIpSpaceSpecifier specifier =
    new ReferenceAddressGroupIpSpaceSpecifier("group1", "book1");
  IpSpace resolvedSpace =
    AclIpSpace.union(
      specifier.resolve(ImmutableSet.of(), ctxt).getEntries().stream()
        .map(e -> e.getIpSpace())
        .collect(Collectors.toSet()));

  assertThat(
    resolvedSpace,
    equalTo(
      AclIpSpace.union(
        new IpWildcard("1.1.1.1").toIpSpace(),
        new IpWildcard("2.2.2.2:0.0.0.8").toIpSpace())));
 }
}
origin: batfish/batfish

 @Test
 public void getAddressBook() throws JsonProcessingException {
  String container = "someContainer";
  Main.getWorkMgr().initNetwork(container, null);

  // write a library to the right place
  ReferenceLibrary.write(
    new ReferenceLibrary(ImmutableList.of(ReferenceBook.builder("book1").build())),
    Main.getWorkMgr().getReferenceLibraryPath(container));

  // we only check that the right type of object is returned at the expected URL target
  // we rely on ReferenceBookBean to have created the object with the right content
  Response response = getAddressBookTarget(container, "book1").get();
  assertThat(response.getStatus(), equalTo(OK.getStatusCode()));
  assertThat(
    response.readEntity(ReferenceBook.class), equalTo(ReferenceBook.builder("book1").build()));

  // should get 404 for non-existent dimension
  Response response2 = getAddressBookTarget(container, "book2").get();
  assertThat(response2.getStatus(), equalTo(NOT_FOUND.getStatusCode()));
 }
}
origin: batfish/batfish

@Test
public void delAddressBook() throws IOException {
 String container = "someContainer";
 Main.getWorkMgr().initNetwork(container, null);
 // write a library to the right place
 ReferenceLibrary.write(
   new ReferenceLibrary(ImmutableList.of(ReferenceBook.builder("book1").build())),
   Main.getWorkMgr().getReferenceLibraryPath(container));
 Response response = getAddressBookTarget(container, "book1").delete();
 // response should be OK and book1 should have disappeared
 assertThat(response.getStatus(), equalTo(OK.getStatusCode()));
 assertThat(
   Main.getWorkMgr().getReferenceLibrary(container).getReferenceBook("book1").isPresent(),
   equalTo(false));
 // deleting again should fail
 Response response2 = getAddressBookTarget(container, "book1").delete();
 assertThat(response2.getStatus(), equalTo(NOT_FOUND.getStatusCode()));
}
origin: batfish/batfish

@Test
public void addReferenceBook() throws IOException {
 String network = "someNetwork";
 Main.getWorkMgr().initNetwork(network, null);
 // add book1
 ReferenceBookBean book = new ReferenceBookBean(ReferenceBook.builder("book1").build());
 Response response =
   getReferenceLibraryTarget(network).post(Entity.entity(book, MediaType.APPLICATION_JSON));
 // test: book1 should have been added
 assertThat(response.getStatus(), equalTo(OK.getStatusCode()));
 ReferenceLibrary library = Main.getWorkMgr().getReferenceLibrary(network);
 assertThat(library.getReferenceBook("book1").isPresent(), equalTo(true));
 // test: another addition of book1 should fail
 Response response2 =
   getReferenceLibraryTarget(network).post(Entity.entity(book, MediaType.APPLICATION_JSON));
 assertThat(response2.getStatus(), equalTo(BAD_REQUEST.getStatusCode()));
}
origin: batfish/batfish

 @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());
 }
}
origin: batfish/batfish

@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)));
}
origin: batfish/batfish

 /** Test if a non-empty library is bean'd properly */
 @Test
 public void constructorNonEmpty() throws IOException {
  ReferenceLibrary library =
    new ReferenceLibrary(
      ImmutableList.of(
        ReferenceBook.builder("book1").build(), ReferenceBook.builder("book2").build()));

  assertThat(
    new ReferenceLibraryBean(library).books,
    equalTo(
      ImmutableSet.of(
        new ReferenceBookBean(ReferenceBook.builder("book1").build()),
        new ReferenceBookBean(ReferenceBook.builder("book2").build()))));
 }
}
origin: batfish/batfish

@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);
}
origin: batfish/batfish

public static Builder builder(String name) {
 return new Builder(name);
}
origin: batfish/batfish

@Test
public void constructorEmptyBook() {
 ReferenceBook book1 = ReferenceBook.builder("book1").build();
 beanBookMatch(new ReferenceBookBean(book1), book1);
}
origin: batfish/batfish

@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)));
}
org.batfish.referencelibraryReferenceBook$Builder

Most used methods

  • build
  • setAddressGroups
  • setInterfaceGroups
  • setFilterGroups
  • setServiceEndpoints
  • setServiceObjectGroups
  • setServiceObjects
  • <init>

Popular in Java

  • Reactive rest calls using spring rest template
  • runOnUiThread (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getApplicationContext (Context)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Path (java.nio.file)
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • HashMap (java.util)
    HashMap is an implementation of Map. All optional operations are supported.All elements are permitte
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now