public void delayedSquaring(final Consumer consumer) {

    var minTimeOut = 5000L;

    SecureRandom secureRandom = new SecureRandom();
    var randomTimeOut = secureRandom.nextInt(2000);

    try {
      // this will make the thread sleep from 5-7s.
      Thread.sleep(minTimeOut + randomTimeOut);
    } catch (InterruptedException e) {
      LOGGER.error("Exception while sleep ", e);
      Thread.currentThread().interrupt();
    } finally {
      consumer.add(number * number);
    }
  }
@Test
  void delayedSquaringTest() {
    Consumer consumer = new Consumer(10L);

    SquareNumberRequest squareNumberRequest = new SquareNumberRequest(5L);

    squareNumberRequest.delayedSquaring(consumer);

    Assertions.assertEquals(35, consumer.getSumOfSquaredNumbers().get());
  }