@Test public void testParsePortMappings() throws Exception { final Map<String, PortMapping> mappings = PortMappingParser.parsePortMappings(testDataToSpecs(GOOD_SPECS)); final Map<String, PortMapping> expectedMappings = new HashMap<>(); for (final TestData d : GOOD_SPECS) { expectedMappings.put(d.getName(), d.getPortMapping()); } assertThat(mappings, equalTo(expectedMappings)); }
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();   }