KeySupplier implements Supplier<String> { @Override public String get() { return String.format("%s/%d_%s", prefix, clock.millis(), randomSuffix.get()); } @Autowired  KeySupplier(@Value("${s3.keyPrefix}") String prefix, Clock clock); @Override String get();  }
@Test public void typical() { when(clock.millis()).thenReturn(123L); KeySupplier underTest = new KeySupplier("prefix", clock); String result = underTest.get(); assertThat(result.matches("prefix/123_[a-zA-Z]{8}"), is(true)); }