@Test
public void pullListenerUnexpectedProgressReporting() {

    dockerClient.newRegistryImage("resolved-image", "latest")
            .pullProgress("layer", "Downloading", 100, 0) // Must avoid dividing by zero.
            .pullProgress("layer", "Downloading", 100, 50)  // Current > total
            .pullProgress("layer", "Downloading", -50, 100).pullProgress("layer", "Downloading", -50, -100);
    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("Downloading", "layer", PullStatusListener.NO_PROGRESS),
                          new ListenerInvocation("Downloading", "layer", PullStatusListener.NO_PROGRESS),
                          new ListenerInvocation("Downloading", "layer", PullStatusListener.NO_PROGRESS),
                          new ListenerInvocation("Downloading", "layer", PullStatusListener.NO_PROGRESS)));
}