MaintenanceScheduleHelper { public static void validateDuration(final String duration) { try { if (StringUtils.hasText(duration)) { convertDurationToLocalTime(duration); } } catch (final DateTimeParseException e) { throw new InvalidMaintenanceScheduleException("Provided duration is not valid", e, e.getErrorIndex()); } } private  MaintenanceScheduleHelper(); @SuppressWarnings("squid:S1166") static Optional<ZonedDateTime> getNextMaintenanceWindow(final String cronSchedule, final String duration,
            final String timezone); static Cron getCronFromExpression(final String cronSchedule); static void validateMaintenanceSchedule(final String cronSchedule, final String duration,
            final String timezone); static Duration convertToISODuration(final String timeInterval); static void validateDuration(final String duration); static void validateCronSchedule(final String cronSchedule);  }
@Test @Description("Verifies that the InvalidMaintenanceScheduleException is thrown for invalid duration format") public void validateDurationInvalid() { final String duration = "10"; assertThatThrownBy(() -> MaintenanceScheduleHelper.validateDuration(duration)) .isInstanceOf(InvalidMaintenanceScheduleException.class).hasMessage("Provided duration is not valid") .extracting("durationErrorIndex").containsExactly(2); }