Tabnine Logo
NodeRole.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.batfish.role.NodeRole
constructor

Best Java code snippets using org.batfish.role.NodeRole.<init> (Showing top 14 results out of 315)

origin: batfish/batfish

 /**
  * Gets a {@link NodeRole} object from this bean.
  *
  * <p>Name and regex may be null in the bean. Error handling happens inside the NodeRole
  * constructor.
  */
 public NodeRole toNodeRole() {
  return new NodeRole(name, regex);
 }
}
origin: batfish/batfish

 @Test
 public void toNodeRole() {
  NodeRoleBean roleBean =
    new NodeRoleBean(new NodeRole("name", "a.*"), ImmutableSet.of("a", "b"));
  NodeRole role = roleBean.toNodeRole();

  assertThat(role, equalTo(new NodeRole("name", "a.*")));
 }
}
origin: batfish/batfish

/** Checks if we properly populate the nodes field */
@Test
public void constructor() {
 NodeRoleBean role = new NodeRoleBean(new NodeRole("name", "a.*"), ImmutableSet.of("a", "b"));
 assertThat(role.nodes, equalTo(ImmutableSet.of("a")));
}
origin: batfish/batfish

private NodeRoleDimension regexToNodeRoleDimension(String regex, String dimName) {
 SortedSet<NodeRole> inferredRoles = new TreeSet<>();
 Set<String> roles = regexToRoleNodesMap(regex, _nodes).keySet();
 for (String role : roles) {
  inferredRoles.add(new NodeRole(role, specializeRegexForRole(role, regex), _caseSensitive));
 }
 return NodeRoleDimension.builder()
   .setName(dimName)
   .setRoles(inferredRoles)
   .setType(Type.AUTO)
   .setRoleRegexes(ImmutableList.of(regex))
   .build();
}
origin: batfish/batfish

 @Test
 public void matches() {
  NodeRole role = new NodeRole("hello", "a.*");

  assertThat(role.matches("a1"), equalTo(true));
  assertThat(role.matches("b1"), equalTo(false));
 }
}
origin: batfish/batfish

    .build();
NodeRole role1 = new NodeRole("match1", "lhr-border.*");
NodeRole role2 = new NodeRole("match2", "svr-border.*");
NodeRole role3 = new NodeRole("dumb0", "lhr-core.*");
SortedSet<NodeRole> roles =
  new ImmutableSortedSet.Builder<>(NodeRole::compareTo)
origin: batfish/batfish

@Test
public void testProperties() {
 String snapshot = "snapshot1";
 String dimension = "someDimension";
 String role = "someRole";
 Set<String> nodes = ImmutableSet.of("a", "b");
 NodeRole nodeRole = new NodeRole(role, "a.*");
 NodeRoleDimension nodeRoleDimension =
   NodeRoleDimension.builder()
     .setName(dimension)
     .setRoles(ImmutableSortedSet.of(nodeRole))
     .build();
 NodeRoleDimensionBean bean = new NodeRoleDimensionBean(nodeRoleDimension, snapshot, nodes);
 assertThat(bean.name, equalTo(dimension));
 assertThat(bean.roles, equalTo(ImmutableSet.of(new NodeRoleBean(nodeRole, nodes))));
 assertThat(bean.snapshot, equalTo(snapshot));
 assertThat(bean.type, equalTo(NodeRoleDimension.Type.CUSTOM));
}
origin: batfish/batfish

@Test
public void testPutNodeRolesDuplicateDimensions() {
 String network = "someContainer";
 Main.getWorkMgr().initNetwork(network, null);
 String name = "auto0";
 NodeRolesDataBean nodeRolesDataBean =
   new NodeRolesDataBean(
     NodeRolesData.builder()
       .setRoleDimensions(
         ImmutableSortedSet.of(
           NodeRoleDimension.builder()
             .setName(name)
             .setRoles(ImmutableSortedSet.of(new NodeRole("foo", "bar")))
             .build(),
           NodeRoleDimension.builder().setName(name).build()))
       .build(),
     null,
     ImmutableSet.of());
 Response response =
   getNodeRolesTarget(network)
     .put(Entity.entity(nodeRolesDataBean, MediaType.APPLICATION_JSON));
 assertThat(response.getStatus(), equalTo(BAD_REQUEST.getStatusCode()));
}
origin: batfish/batfish

@Test
public void testNoDuplicateDimensionsSameName() {
 String name = "auto0";
 NodeRolesDataBean nodeRolesDataBean =
   new NodeRolesDataBean(
     NodeRolesData.builder()
       .setRoleDimensions(
         ImmutableSortedSet.of(
           NodeRoleDimension.builder()
             .setName(name)
             .setRoles(ImmutableSortedSet.of(new NodeRole("foo", "bar")))
             .build(),
           NodeRoleDimension.builder().setName(name).build()))
       .build(),
     null,
     ImmutableSet.of());
 assertThat(noDuplicateDimensions(nodeRolesDataBean), equalTo(false));
}
origin: batfish/batfish

 @Test
 public void testProperties() throws IOException {
  String snapshot = "snapshot1";
  String dimension = "someDimension";
  String role = "someRole";
  Set<String> nodes = ImmutableSet.of("a", "b");
  NodeRole nodeRole = new NodeRole(role, "a.*");
  NodeRoleDimension nodeRoleDimension =
    NodeRoleDimension.builder()
      .setName(dimension)
      .setRoles(ImmutableSortedSet.of(nodeRole))
      .build();
  NodeRolesData data =
    NodeRolesData.builder().setRoleDimensions(ImmutableSortedSet.of(nodeRoleDimension)).build();
  NodeRolesDataBean bean = new NodeRolesDataBean(data, snapshot, nodes);

  assertThat(
    bean.roleDimensions,
    equalTo(ImmutableSet.of(new NodeRoleDimensionBean(nodeRoleDimension, snapshot, nodes))));
  assertThat(bean.defaultDimension, nullValue());
 }
}
origin: batfish/batfish

private NodeRolesData initNodeRoleData() {
 NodeRoleDimension dim1 =
   NodeRoleDimension.builder()
     .setName("dim10")
     .setRoles(
       new ImmutableSortedSet.Builder<>(NodeRole::compareTo)
         .add(new NodeRole("role1", ".*"))
         .add(new NodeRole("role2", ".*"))
         .build())
     .build();
 NodeRoleDimension dim2 =
   NodeRoleDimension.builder()
     .setName("dim20")
     .setRoles(
       new ImmutableSortedSet.Builder<>(NodeRole::compareTo)
         .add(new NodeRole("role1", ".*"))
         .add(new NodeRole("role2", ".*"))
         .build())
     .build();
 SortedSet<NodeRoleDimension> roleDimensions =
   new ImmutableSortedSet.Builder<>(NodeRoleDimension::compareTo).add(dim1).add(dim2).build();
 return NodeRolesData.builder().setRoleDimensions(roleDimensions).build();
}
origin: batfish/batfish

@Test
public void testGetNetworkNodeRolesGoodSnapshot() throws IOException {
 String network = "network1";
 String snapshot = "snapshot1";
 String node = "node1";
 _manager.initNetwork(network, null);
 NetworkId networkId = _idManager.getNetworkId(network);
 WorkMgrTestUtils.uploadTestSnapshot(network, snapshot, node, _folder);
 SnapshotId snapshotId = _idManager.getSnapshotId(snapshot, networkId);
 NodeRolesId snapshotNodeRolesId = _idManager.getSnapshotNodeRolesId(networkId, snapshotId);
 NodeRolesData snapshotInferredNodeRoles =
   NodeRolesData.builder()
     .setRoleDimensions(
       ImmutableSortedSet.of(
         NodeRoleDimension.builder()
           .setName("dim1")
           .setRoles(ImmutableSet.of(new NodeRole("role1", node)))
           .build()))
     .build();
 _manager.getStorage().storeNodeRoles(snapshotInferredNodeRoles, snapshotNodeRolesId);
 SnapshotMetadataMgr.updateInitializationStatus(
   networkId, snapshotId, ProcessingStatus.PARSED, null);
 // inferred roles for first snapshot should have been set network-wide
 assertThat(_manager.getNetworkNodeRoles(network), equalTo(snapshotInferredNodeRoles));
}
origin: batfish/batfish

@Test
public void testGetNetworkNodeRolesNoGoodSnapshots() throws IOException {
 String network = "network1";
 String snapshot = "snapshot1";
 String node = "node1";
 _manager.initNetwork(network, null);
 NetworkId networkId = _idManager.getNetworkId(network);
 WorkMgrTestUtils.uploadTestSnapshot(network, snapshot, node, _folder);
 SnapshotId snapshotId = _idManager.getSnapshotId(snapshot, networkId);
 NodeRolesId snapshotNodeRolesId = _idManager.getSnapshotNodeRolesId(networkId, snapshotId);
 NodeRolesData snapshotInferredNodeRoles =
   NodeRolesData.builder()
     .setRoleDimensions(
       ImmutableSortedSet.of(
         NodeRoleDimension.builder()
           .setName("dim1")
           .setRoles(ImmutableSet.of(new NodeRole("role1", node)))
           .build()))
     .build();
 _manager.getStorage().storeNodeRoles(snapshotInferredNodeRoles, snapshotNodeRolesId);
 SnapshotMetadataMgr.updateInitializationStatus(
   networkId, snapshotId, ProcessingStatus.PARSING_FAIL, null);
 // should return empty node roles since snapshot parsing failed
 assertThat(_manager.getNetworkNodeRoles(network), equalTo(NodeRolesData.builder().build()));
}
origin: batfish/batfish

@Test
public void testGetNetworkNodeRolesUnchangedOnceSet() throws IOException {
 String network = "network1";
 String snapshot = "snapshot1";
 String node = "node1";
 _manager.initNetwork(network, null);
 NetworkId networkId = _idManager.getNetworkId(network);
 NodeRolesData manualRoles = NodeRolesData.builder().build();
 _manager.putNetworkNodeRoles(manualRoles, network);
 WorkMgrTestUtils.uploadTestSnapshot(network, snapshot, node, _folder);
 SnapshotId snapshotId = _idManager.getSnapshotId(snapshot, networkId);
 NodeRolesId snapshotNodeRolesId = _idManager.getSnapshotNodeRolesId(networkId, snapshotId);
 NodeRolesData snapshotInferredNodeRoles =
   NodeRolesData.builder()
     .setRoleDimensions(
       ImmutableSortedSet.of(
         NodeRoleDimension.builder()
           .setName("dim1")
           .setRoles(ImmutableSet.of(new NodeRole("role1", node)))
           .build()))
     .build();
 _manager.getStorage().storeNodeRoles(snapshotInferredNodeRoles, snapshotNodeRolesId);
 SnapshotMetadataMgr.updateInitializationStatus(
   networkId, snapshotId, ProcessingStatus.PARSED, null);
 // network node roles should not have changed since they had already been set
 assertThat(_manager.getNetworkNodeRoles(network), equalTo(manualRoles));
}
org.batfish.roleNodeRole<init>

Popular methods of NodeRole

  • getName
  • matches
    Does the provided node name belong to this role?
  • getRegex

Popular in Java

  • Updating database using SQL prepared statement
  • runOnUiThread (Activity)
  • startActivity (Activity)
  • compareTo (BigDecimal)
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Top PhpStorm plugins
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