public AdvancedNetworkConfig setEndpointConfigs(Map<EndpointQualifier, EndpointConfig> endpointConfigs) {
        // sanitize input
        for (Map.Entry<EndpointQualifier, EndpointConfig> entry : endpointConfigs.entrySet()) {
            entry.getValue().setProtocolType(entry.getKey().getType());
        }
        // validate
        for (ProtocolType protocolType : ProtocolType.values()) {
            int count = countEndpointConfigs(endpointConfigs, protocolType);
            if (count > protocolType.getServerSocketCardinality()) {
                throw new InvalidConfigurationException("Protocol type " + protocolType + " does not allow more than "
                        + protocolType.getServerSocketCardinality() + " server sockets but " + count + " were defined");
            }
        }
        this.endpointConfigs.clear();
        this.endpointConfigs.putAll(endpointConfigs);
        return this;
    }
@Test
    public void test_setEndpointConfigs_throwsException_whenServerSocketCardinalityBroken() throws Exception {
        IdentityHashMap<EndpointQualifier, EndpointConfig> offendingEndpointConfigs =
                new IdentityHashMap<>();
        EndpointQualifier one = createReflectively(ProtocolType.MEMBER, "1");
        EndpointQualifier two = createReflectively(ProtocolType.MEMBER, "2");
        offendingEndpointConfigs.put(one, new ServerSocketEndpointConfig());
        offendingEndpointConfigs.put(two, new ServerSocketEndpointConfig());

        AdvancedNetworkConfig config = new AdvancedNetworkConfig();
        Assert.assertThrows(InvalidConfigurationException.class, () -> config.setEndpointConfigs(offendingEndpointConfigs));
    }