I can't figure out how to test this. Tell me please good literature or vebinar on this topic
public InputMessenger getInputForMessengerFromConsole() {
    String templateValue;
    Map<String, String> valuesForTemplate = new HashMap<>();
    try (Scanner scanner = new Scanner(System.in, Constant.CHARSET_NAME_UTF_8)) {
        System.out.println(Constant.MESSAGE_INPUT_TEMPLATE);
        templateValue = scanner.nextLine();
        System.out.println(Constant.MESSAGE_NUMBER_OF_VALUES);
        int numberOfValues = scanner.nextInt();
        scanner.nextLine();
        IntStream.range(0, numberOfValues).forEach(index -> {
            System.out.println(Constant.MESSAGE_KEY + (index + Constant.INT_ONE) + Constant.COLON);
            String key = scanner.nextLine();
            System.out.println(Constant.MESSAGE_VALUE + (index + Constant.INT_ONE) + Constant.COLON);
            String value = scanner.nextLine();
            valuesForTemplate.put(key, value);
        });
    }
    return new InputMessenger(templateValue, valuesForTemplate);
}
 
    