@Test
public void pullListener() {

    dockerClient.newRegistryImage("resolved-image", "latest").pullProgress("layer1", "Pulling fs layer", null, null)
            .pullProgress("layer1", "Downloading", 0, 100).pullProgress("layer2", "Pulling fs layer", null, null)
            .pullProgress("layer2", "Downloading", 0, new BigInteger("10000000000"))
            .pullProgress("layer1", "Downloading", 50, 100).pullProgress("layer1", "Downloading", 100, 100)
            .pullProgress("layer1", "Pull complete", null, null)
            .pullProgress("layer2", "Downloading", new BigInteger("2500000000"), new BigInteger("10000000000"))
            .pullProgress("layer2", "Downloading", new BigInteger("10000000000"), new BigInteger("10000000000"))
            .pullProgress("layer2", "Pull complete", null, null);
    DefaultDockerClientFacade facade = new DefaultDockerClientFacade(dockerClient);
    List<ListenerInvocation> invocations = new ArrayList<>();
    facade.createAgent(CreateAgentParameters.from(Node.EMPTY_OBJECT).
            imageName("resolved-image:latest").
            pullStrategy(PullStrategy.PULL).
            pullStatusListener((status, layer, percent) ->
                                       invocations.add(new ListenerInvocation(status, layer, percent))));
    assertThat(invocations).isEqualTo(
            Arrays.asList(new ListenerInvocation( "Pulling fs layer","layer1", PullStatusListener.NO_PROGRESS),
                          new ListenerInvocation( "Downloading","layer1", 0),
                          new ListenerInvocation( "Pulling fs layer","layer2", PullStatusListener.NO_PROGRESS),
                          new ListenerInvocation( "Downloading","layer2", 0),
                          new ListenerInvocation( "Downloading","layer1", 50),
                          new ListenerInvocation( "Downloading","layer1", 100),
                          new ListenerInvocation( "Pull complete","layer1", PullStatusListener.NO_PROGRESS),
                          new ListenerInvocation( "Downloading","layer2", 25),
                          new ListenerInvocation( "Downloading","layer2", 100),
                          new ListenerInvocation( "Pull complete","layer2", PullStatusListener.NO_PROGRESS)));
}