Home / Class/ TotalProgressListenerTests Class — spring-boot Architecture

TotalProgressListenerTests Class — spring-boot Architecture

Architecture documentation for the TotalProgressListenerTests class in TotalProgressListenerTests.java from the spring-boot codebase.

Entity Profile

Relationship Graph

Source Code

buildpack/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/TotalProgressListenerTests.java lines 39–96

class TotalProgressListenerTests extends AbstractJsonTests {

	@Test
	void totalProgress() throws Exception {
		List<Integer> progress = new ArrayList<>();
		TestTotalProgressListener listener = new TestTotalProgressListener((event) -> progress.add(event.getPercent()));
		run(listener);
		int last = 0;
		for (Integer update : progress) {
			assertThat(update).isGreaterThanOrEqualTo(last);
			last = update;
		}
		assertThat(last).isEqualTo(100);
	}

	@Test
	@Disabled("For visual inspection")
	void totalProgressUpdatesSmoothly() throws Exception {
		TestTotalProgressListener listener = new TestTotalProgressListener(new TotalProgressBar("Pulling layers:"));
		run(listener);
	}

	private void run(TestTotalProgressListener listener) throws IOException {
		JsonStream jsonStream = new JsonStream(getJsonMapper());
		listener.onStart();
		jsonStream.get(getContent("pull-stream.json"), TestImageUpdateEvent.class, listener::onUpdate);
		listener.onFinish();
	}

	private static class TestTotalProgressListener extends TotalProgressListener<TestImageUpdateEvent> {

		TestTotalProgressListener(Consumer<TotalProgressEvent> consumer) {
			super(consumer, new String[] { "Pulling", "Downloading", "Extracting" });
		}

		@Override
		public void onUpdate(TestImageUpdateEvent event) {
			super.onUpdate(event);
			try {
				Thread.sleep(10);
			}
			catch (InterruptedException ex) {
				// Ignore
			}
		}

	}

	private static class TestImageUpdateEvent extends ImageProgressUpdateEvent {

		@JsonCreator
		TestImageUpdateEvent(String id, String status, ProgressDetail progressDetail, String progress) {
			super(id, status, progressDetail, progress);
		}

	}

}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free