Merge branch '3.3.x'

Closes gh-43356
This commit is contained in:
Phillip Webb
2024-12-02 13:59:53 -08:00
4 changed files with 56 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2023 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @param <E> The event type
* @author Phillip Webb
* @author Scott Frederick
* @author Wolfgang Kronberg
*/
abstract class ProgressUpdateEventTests<E extends ProgressUpdateEvent> {
@@ -38,10 +39,21 @@ abstract class ProgressUpdateEventTests<E extends ProgressUpdateEvent> {
}
@Test
@SuppressWarnings("removal")
void getProgressDetailsReturnsProgressDetails() {
ProgressUpdateEvent event = createEvent();
assertThat(event.getProgressDetail().getCurrent()).isOne();
assertThat(event.getProgressDetail().getTotal()).isEqualTo(2);
assertThat(event.getProgressDetail().asPercentage()).isEqualTo(50);
}
@Test
@SuppressWarnings("removal")
void getProgressDetailsReturnsProgressDetailsForLongNumbers() {
ProgressUpdateEvent event = createEvent("status", new ProgressDetail(4000000000L, 8000000000L), "progress");
assertThat(event.getProgressDetail().getCurrent()).isEqualTo(Integer.MAX_VALUE);
assertThat(event.getProgressDetail().getTotal()).isEqualTo(Integer.MAX_VALUE);
assertThat(event.getProgressDetail().asPercentage()).isEqualTo(50);
}
@Test
@@ -51,25 +63,28 @@ abstract class ProgressUpdateEventTests<E extends ProgressUpdateEvent> {
}
@Test
@SuppressWarnings("removal")
void progressDetailIsEmptyWhenCurrentIsNullReturnsTrue() {
ProgressDetail detail = new ProgressDetail(null, 2);
ProgressDetail detail = new ProgressDetail(null, 2L);
assertThat(ProgressDetail.isEmpty(detail)).isTrue();
}
@Test
@SuppressWarnings("removal")
void progressDetailIsEmptyWhenTotalIsNullReturnsTrue() {
ProgressDetail detail = new ProgressDetail(1, null);
ProgressDetail detail = new ProgressDetail(1L, null);
assertThat(ProgressDetail.isEmpty(detail)).isTrue();
}
@Test
@SuppressWarnings("removal")
void progressDetailIsEmptyWhenTotalAndCurrentAreNotNullReturnsFalse() {
ProgressDetail detail = new ProgressDetail(1, 2);
ProgressDetail detail = new ProgressDetail(1L, 2L);
assertThat(ProgressDetail.isEmpty(detail)).isFalse();
}
protected E createEvent() {
return createEvent("status", new ProgressDetail(1, 2), "progress");
return createEvent("status", new ProgressDetail(1L, 2L), "progress");
}
protected abstract E createEvent(String status, ProgressDetail progressDetail, String progress);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class PullUpdateEventTests extends AbstractJsonTests {
@Test
@SuppressWarnings("removal")
void readValueWhenFullDeserializesJson() throws Exception {
PullImageUpdateEvent event = getObjectMapper().readValue(getContent("pull-update-full.json"),
PullImageUpdateEvent.class);
@@ -37,6 +38,7 @@ class PullUpdateEventTests extends AbstractJsonTests {
assertThat(event.getStatus()).isEqualTo("Extracting");
assertThat(event.getProgressDetail().getCurrent()).isEqualTo(16);
assertThat(event.getProgressDetail().getTotal()).isEqualTo(32);
assertThat(event.getProgressDetail().asPercentage()).isEqualTo(50);
assertThat(event.getProgress()).isEqualTo("[==================================================>] 32B/32B");
}