// Path: src/main/java/pl/domzal/junit/docker/rule/ex/InvalidPortDefinition.java
// public class InvalidPortDefinition extends IllegalStateException {
// 
//     public InvalidPortDefinition(String port) {
//         super("Invalid port: "+port);
//     }
// 
// }


import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Lists;
import com.spotify.docker.client.messages.HostConfig;
import com.spotify.docker.client.messages.PortBinding;
import pl.domzal.junit.docker.rule.ex.InvalidPortDefinition;
        assertValidContainerPort(containerPort);
        assertHostPortNotAssigned(hostPort);
        addBinding(Ports.portWithProtocol(containerPort), PortBinding.of(BIND_ALL, hostPort));
        return this;
    }

    public ExposePortBindingBuilder expose(String containerPort) {
        assertValidContainerPort(containerPort);
        addBinding(Ports.portWithProtocol(containerPort), PortBinding.randomPort(BIND_ALL));
        return this;
    }

    private void addBinding(String containerBind, PortBinding hostBind) {
        if (bindings.containsKey(containerBind)) {
            bindings.get(containerBind).add(hostBind);
        } else {
            bindings.put(containerBind, Lists.newArrayList(hostBind));
        }
    }

    Map<String, List<PortBinding>> hostBindings() {
        return bindings;
    }

    Set<String> containerExposedPorts() {
        return bindings.keySet();
    }

    private void assertIsNumber(String portToCheck) {
        if ( ! StringUtils.isNumeric(portToCheck) ) {
// Path: src/main/java/pl/domzal/junit/docker/rule/ex/InvalidPortDefinition.java
// public class InvalidPortDefinition extends IllegalStateException {
// 
//     public InvalidPortDefinition(String port) {
//         super("Invalid port: "+port);
//     }
// 
// }


// Path: src/main/java/pl/domzal/junit/docker/rule/ExposePortBindingBuilder.java
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Lists;
import com.spotify.docker.client.messages.HostConfig;
import com.spotify.docker.client.messages.PortBinding;
import pl.domzal.junit.docker.rule.ex.InvalidPortDefinition;

        assertValidContainerPort(containerPort);
        assertHostPortNotAssigned(hostPort);
        addBinding(Ports.portWithProtocol(containerPort), PortBinding.of(BIND_ALL, hostPort));
        return this;
    }

    public ExposePortBindingBuilder expose(String containerPort) {
        assertValidContainerPort(containerPort);
        addBinding(Ports.portWithProtocol(containerPort), PortBinding.randomPort(BIND_ALL));
        return this;
    }

    private void addBinding(String containerBind, PortBinding hostBind) {
        if (bindings.containsKey(containerBind)) {
            bindings.get(containerBind).add(hostBind);
        } else {
            bindings.put(containerBind, Lists.newArrayList(hostBind));
        }
    }

    Map<String, List<PortBinding>> hostBindings() {
        return bindings;
    }

    Set<String> containerExposedPorts() {
        return bindings.keySet();
    }

    private void assertIsNumber(String portToCheck) {
        if ( ! StringUtils.isNumeric(portToCheck) ) {
            throw new InvalidPortDefinition(portToCheck);