@Test public void testParsePortMappingsDuplicateName() throws Exception { final ImmutableList<TestData> specs = ImmutableList.<TestData>builder() .addAll(GOOD_SPECS) .add(GOOD_SPECS.get(0)) .build(); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Duplicate port mapping name: " + GOOD_SPECS.get(0).getName()); PortMappingParser.parsePortMappings(testDataToSpecs(specs)); }
static Map<String, PortMapping> parsePortMappings(final List<String> portSpecs) { final Map<String, PortMapping> explicitPorts = Maps.newHashMap(); for (final String spec : portSpecs) { final PortMappingWithName portMappingWithName = parsePortMapping(spec); final String name = portMappingWithName.name(); if (explicitPorts.containsKey(name)) { throw new IllegalArgumentException("Duplicate port mapping name: " + name); } explicitPorts.put(name, portMappingWithName.portMapping()); } return ImmutableMap.copyOf(explicitPorts); }
PortMappingParser { static Map<String, PortMapping> parsePortMappings(final List<String> portSpecs) { final Map<String, PortMapping> explicitPorts = Maps.newHashMap(); for (final String spec : portSpecs) { final PortMappingWithName portMappingWithName = parsePortMapping(spec); final String name = portMappingWithName.name(); if (explicitPorts.containsKey(name)) { throw new IllegalArgumentException("Duplicate port mapping name: " + name); } explicitPorts.put(name, portMappingWithName.portMapping()); } return ImmutableMap.copyOf(explicitPorts); } }
PortMappingParser { static Map<String, PortMapping> parsePortMappings(final List<String> portSpecs) { final Map<String, PortMapping> explicitPorts = Maps.newHashMap(); for (final String spec : portSpecs) { final PortMappingWithName portMappingWithName = parsePortMapping(spec); final String name = portMappingWithName.name(); if (explicitPorts.containsKey(name)) { throw new IllegalArgumentException("Duplicate port mapping name: " + name); } explicitPorts.put(name, portMappingWithName.portMapping()); } return ImmutableMap.copyOf(explicitPorts); } private  PortMappingParser(); }
PortMappingParser { static Map<String, PortMapping> parsePortMappings(final List<String> portSpecs) { final Map<String, PortMapping> explicitPorts = Maps.newHashMap(); for (final String spec : portSpecs) { final PortMappingWithName portMappingWithName = parsePortMapping(spec); final String name = portMappingWithName.name(); if (explicitPorts.containsKey(name)) { throw new IllegalArgumentException("Duplicate port mapping name: " + name); } explicitPorts.put(name, portMappingWithName.portMapping()); } return ImmutableMap.copyOf(explicitPorts); } private  PortMappingParser();  }
PortMappingParser { static Map<String, PortMapping> parsePortMappings(final List<String> portSpecs) { final Map<String, PortMapping> explicitPorts = Maps.newHashMap(); for (final String spec : portSpecs) { final PortMappingWithName portMappingWithName = parsePortMapping(spec); final String name = portMappingWithName.name(); if (explicitPorts.containsKey(name)) { throw new IllegalArgumentException("Duplicate port mapping name: " + name); } explicitPorts.put(name, portMappingWithName.portMapping()); } return ImmutableMap.copyOf(explicitPorts); } private  PortMappingParser();   }