@Test public void testAllocate() throws Exception { final PortAllocator sut = new PortAllocator(20000, 20010); final Map<String, PortMapping> mapping = ImmutableMap.of("p1", PortMapping.of(17), "p2", PortMapping.of(18, 18)); final Set<Integer> used = ImmutableSet.of(10, 11); final Map<String, Integer> allocation = sut.allocate(mapping, used); assertThat(allocation, hasEntry(is("p1"), allOf(greaterThanOrEqualTo(20000), lessThanOrEqualTo(20010)))); assertThat(allocation, hasEntry("p2", 18)); }
public Map<String, Integer> allocate(final Map<String, PortMapping> ports, final Set<Integer> used) { return allocate0(ports, Sets.newHashSet(used)); }
PortAllocator { public Map<String, Integer> allocate(final Map<String, PortMapping> ports, final Set<Integer> used) { return allocate0(ports, Sets.newHashSet(used)); } }
PortAllocator { public Map<String, Integer> allocate(final Map<String, PortMapping> ports, final Set<Integer> used) { return allocate0(ports, Sets.newHashSet(used)); } PortAllocator(final int start, final int end); }
PortAllocator { public Map<String, Integer> allocate(final Map<String, PortMapping> ports, final Set<Integer> used) { return allocate0(ports, Sets.newHashSet(used)); } PortAllocator(final int start, final int end); Map<String, Integer> allocate(final Map<String, PortMapping> ports,
                                       final Set<Integer> used); }
PortAllocator { public Map<String, Integer> allocate(final Map<String, PortMapping> ports, final Set<Integer> used) { return allocate0(ports, Sets.newHashSet(used)); } PortAllocator(final int start, final int end); Map<String, Integer> allocate(final Map<String, PortMapping> ports,
                                       final Set<Integer> used);  }