Codota Logo
NodeRole.<init>
Code IndexAdd Codota 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)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
DateTime d =
  • Codota Iconnew DateTime()
  • Codota IconDateTimeFormatter formatter;String text;formatter.parseDateTime(text)
  • Codota IconObject instant;new DateTime(instant)
  • Smart code suggestions by Codota
}
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

  • Reading from database using SQL prepared statement
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • setContentView (Activity)
  • requestLocationUpdates (LocationManager)
  • PrintStream (java.io)
    A PrintStream adds functionality to another output stream, namely the ability to print representatio
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Collectors (java.util.stream)
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now