@Test public void testNoDuplicateRoleMappingsSameName() { String name = "auto0"; NodeRolesDataBean nodeRolesDataBean = new NodeRolesDataBean( NodeRolesData.builder() .setRoleMappings( ImmutableList.of( new RoleMapping(name, "", null, null), new RoleMapping(name, "", null, null))) .build(), null); assertThat(noDuplicateRoleMappings(nodeRolesDataBean), equalTo(false)); }
@VisibleForTesting static boolean noDuplicateRoleMappings(NodeRolesDataBean nodeRolesDataBean) { if (nodeRolesDataBean.roleMappings == null) { return true; } List<String> names = nodeRolesDataBean.roleMappings.stream() .map(bean -> bean.name) .filter(Objects::nonNull) .map(String::toLowerCase) .collect(Collectors.toList()); return names.size() == ImmutableSet.copyOf(names).size(); }
NetworkNodeRolesResource { @VisibleForTesting static boolean noDuplicateRoleMappings(NodeRolesDataBean nodeRolesDataBean) { if (nodeRolesDataBean.roleMappings == null) { return true; } List<String> names = nodeRolesDataBean.roleMappings.stream() .map(bean -> bean.name) .filter(Objects::nonNull) .map(String::toLowerCase) .collect(Collectors.toList()); return names.size() == ImmutableSet.copyOf(names).size(); } }
NetworkNodeRolesResource { @VisibleForTesting static boolean noDuplicateRoleMappings(NodeRolesDataBean nodeRolesDataBean) { if (nodeRolesDataBean.roleMappings == null) { return true; } List<String> names = nodeRolesDataBean.roleMappings.stream() .map(bean -> bean.name) .filter(Objects::nonNull) .map(String::toLowerCase) .collect(Collectors.toList()); return names.size() == ImmutableSet.copyOf(names).size(); } NetworkNodeRolesResource(String network); }
NetworkNodeRolesResource { @VisibleForTesting static boolean noDuplicateRoleMappings(NodeRolesDataBean nodeRolesDataBean) { if (nodeRolesDataBean.roleMappings == null) { return true; } List<String> names = nodeRolesDataBean.roleMappings.stream() .map(bean -> bean.name) .filter(Objects::nonNull) .map(String::toLowerCase) .collect(Collectors.toList()); return names.size() == ImmutableSet.copyOf(names).size(); } NetworkNodeRolesResource(String network); @Deprecated @POST Response addNodeRoleDimension(NodeRoleDimensionBean dimBean); @Path("/{dimension}") NetworkNodeRoleDimensionResource getNodeRoleDimensionResource(
      @PathParam("dimension") String dimension); @GET Response getNodeRoles(); @Consumes(MediaType.APPLICATION_JSON) @PUT Response putNodeRoles(NodeRolesDataBean nodeRolesDataBean); }
NetworkNodeRolesResource { @VisibleForTesting static boolean noDuplicateRoleMappings(NodeRolesDataBean nodeRolesDataBean) { if (nodeRolesDataBean.roleMappings == null) { return true; } List<String> names = nodeRolesDataBean.roleMappings.stream() .map(bean -> bean.name) .filter(Objects::nonNull) .map(String::toLowerCase) .collect(Collectors.toList()); return names.size() == ImmutableSet.copyOf(names).size(); } NetworkNodeRolesResource(String network); @Deprecated @POST Response addNodeRoleDimension(NodeRoleDimensionBean dimBean); @Path("/{dimension}") NetworkNodeRoleDimensionResource getNodeRoleDimensionResource(
      @PathParam("dimension") String dimension); @GET Response getNodeRoles(); @Consumes(MediaType.APPLICATION_JSON) @PUT Response putNodeRoles(NodeRolesDataBean nodeRolesDataBean);  }