// 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 static org.junit.Assert.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.spotify.docker.client.messages.PortBinding;
import pl.domzal.junit.docker.rule.ex.InvalidPortDefinition;
    }

    @Test
    public void shouldMergeTwoTcpPorts() {
        //when
        builder.expose("8181", "80").expose("7171", "80");
        Set<String> containerExposedPorts = builder.containerExposedPorts();
        Map<String, List<PortBinding>> hostBindings = builder.hostBindings();

        //then
        assertEquals(1, containerExposedPorts.size());
        assertTrue(containerExposedPorts.contains("80/tcp"));
        assertEquals(1, hostBindings.size());
        assertTrue(hostBindings.containsKey("80/tcp"));
        // 80 bind
        List<PortBinding> binds80 = hostBindings.get("80/tcp");
        assertEquals(2, binds80.size());
        assertEquals(PortBinding.of(BIND_ALL, 8181), binds80.get(0));
        assertEquals(PortBinding.of(BIND_ALL, 7171), binds80.get(1));
    }

    @Test(expected=IllegalStateException.class)
    public void shouldFailOnHostPortExposeDuplicated() {
        builder.expose("8080", "70").expose("8080", "70");
    }

    public void shouldNotFailWhenExposedSamePortDifferentProtocols() {
        builder.expose("8080", "70").expose("8080", "70/udp");
    }

// 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/test/java/pl/domzal/junit/docker/rule/ExposePortBindingBuilderTest.java
import static org.junit.Assert.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import com.spotify.docker.client.messages.PortBinding;
import pl.domzal.junit.docker.rule.ex.InvalidPortDefinition;

    }

    @Test
    public void shouldMergeTwoTcpPorts() {
        //when
        builder.expose("8181", "80").expose("7171", "80");
        Set<String> containerExposedPorts = builder.containerExposedPorts();
        Map<String, List<PortBinding>> hostBindings = builder.hostBindings();

        //then
        assertEquals(1, containerExposedPorts.size());
        assertTrue(containerExposedPorts.contains("80/tcp"));
        assertEquals(1, hostBindings.size());
        assertTrue(hostBindings.containsKey("80/tcp"));
        // 80 bind
        List<PortBinding> binds80 = hostBindings.get("80/tcp");
        assertEquals(2, binds80.size());
        assertEquals(PortBinding.of(BIND_ALL, 8181), binds80.get(0));
        assertEquals(PortBinding.of(BIND_ALL, 7171), binds80.get(1));
    }

    @Test(expected=IllegalStateException.class)
    public void shouldFailOnHostPortExposeDuplicated() {
        builder.expose("8080", "70").expose("8080", "70");
    }

    public void shouldNotFailWhenExposedSamePortDifferentProtocols() {
        builder.expose("8080", "70").expose("8080", "70/udp");
    }

    @Test(expected=InvalidPortDefinition.class)