@Test public void inferRolesOnExampleTopology() { Optional<RoleMapping> roleMappingOpt = new InferRoles(EXAMPLE_NODES, EXAMPLE_TOPOLOGY).inferRoles(); assertTrue(roleMappingOpt.isPresent()); RoleMapping roleMapping = roleMappingOpt.get(); assertThat(roleMapping.getRegex(), equalTo("(\\p{Alpha}+)\\p{Digit}+(\\p{Alpha}+)\\p{Digit}+")); assertThat(roleMapping.getRoleDimensionsGroups().entrySet(), hasSize(2)); for (Map.Entry<String, List<Integer>> entry : roleMapping.getRoleDimensionsGroups().entrySet()) { String dimName = entry.getKey(); List<Integer> groups = entry.getValue(); if (dimName.equals(NodeRoleDimension.AUTO_DIMENSION_PRIMARY)) { assertThat(groups, equalTo(ImmutableList.of(2))); } else if (dimName.equals(NodeRoleDimension.AUTO_DIMENSION_PREFIX + "1")) { assertThat(groups, equalTo(ImmutableList.of(1))); } else { fail(); } } assertTrue(roleMapping.getCanonicalRoleNames().isEmpty()); }
public InferRoles(Collection<String> nodes, Topology topology) { _nodes = ImmutableSortedSet.copyOf(nodes); _topology = topology; }
InferRoles { public InferRoles(Collection<String> nodes, Topology topology) { _nodes = ImmutableSortedSet.copyOf(nodes); _topology = topology; } }
InferRoles { public InferRoles(Collection<String> nodes, Topology topology) { _nodes = ImmutableSortedSet.copyOf(nodes); _topology = topology; } InferRoles(Collection<String> nodes, Topology topology); }
InferRoles { public InferRoles(Collection<String> nodes, Topology topology) { _nodes = ImmutableSortedSet.copyOf(nodes); _topology = topology; } InferRoles(Collection<String> nodes, Topology topology); Optional<RoleMapping> inferRoles(); }
InferRoles { public InferRoles(Collection<String> nodes, Topology topology) { _nodes = ImmutableSortedSet.copyOf(nodes); _topology = topology; } InferRoles(Collection<String> nodes, Topology topology); Optional<RoleMapping> inferRoles();  }