test_class.file: spring/shedlock-spring/src/test/java/net/javacrumbs/shedlock/spring/aop/StringToDurationConverterTest.java
test_class.identifier: StringToDurationConverterTest
test_case.body: @Test
      public void convertWhenIso8601ShouldReturnDuration() {
          assertThat(convert("PT20.345S")).isEqualTo(Duration.parse("PT20.345S"));
          assertThat(convert("PT15M")).isEqualTo(Duration.parse("PT15M"));
          assertThat(convert("+PT15M")).isEqualTo(Duration.parse("PT15M"));
          assertThat(convert("PT10H")).isEqualTo(Duration.parse("PT10H"));
          assertThat(convert("P2D")).isEqualTo(Duration.parse("P2D"));
          assertThat(convert("P2DT3H4M")).isEqualTo(Duration.parse("P2DT3H4M"));
          assertThat(convert("-PT6H3M")).isEqualTo(Duration.parse("-PT6H3M"));
          assertThat(convert("-PT-6H+3M")).isEqualTo(Duration.parse("-PT-6H+3M"));
      }
test_case.class_method_signature: StringToDurationConverterTest.convertWhenIso8601ShouldReturnDuration()
test_case.full_signature: @Test public void convertWhenIso8601ShouldReturnDuration()
test_case.identifier: convertWhenIso8601ShouldReturnDuration
test_case.invocations: isEqualTo assertThat convert parse isEqualTo assertThat convert parse isEqualTo assertThat convert parse isEqualTo assertThat convert parse isEqualTo assertThat convert parse isEqualTo assertThat convert parse isEqualTo assertThat convert parse isEqualTo assertThat convert parse
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void convertWhenIso8601ShouldReturnDuration()
focal_class.declarator: INSTANCE = new StringToDurationConverter()
focal_class.modifier: static final
focal_class.original_string: static final StringToDurationConverter INSTANCE = new StringToDurationConverter();
focal_class.type: StringToDurationConverter
focal_class.var_name: INSTANCE
focal_class.declarator: ISO8601 = Pattern.compile("^[\\+\\-]?P.*$")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern ISO8601 = Pattern.compile("^[\\+\\-]?P.*$");
focal_class.type: Pattern
focal_class.var_name: ISO8601
focal_class.declarator: SIMPLE = Pattern.compile("^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$")
focal_class.modifier: private static final
focal_class.original_string: private static final Pattern SIMPLE = Pattern.compile("^([\\+\\-]?\\d+)([a-zA-Z]{0,2})$");
focal_class.type: Pattern
focal_class.var_name: SIMPLE
focal_class.declarator: UNITS
focal_class.modifier: private static final
focal_class.original_string: private static final Map<String, ChronoUnit> UNITS;
focal_class.type: Map<String, ChronoUnit>
focal_class.var_name: UNITS
focal_class.file: spring/shedlock-spring/src/main/java/net/javacrumbs/shedlock/spring/aop/StringToDurationConverter.java
focal_class.identifier: StringToDurationConverter
focal_class.interfaces: implements Converter<String, Duration>
focal_class.class_method_signature: StringToDurationConverter.convert(String source)
focal_class.full_signature: @Override public Duration convert(String source)
focal_class.identifier: convert
focal_class.modifiers: @Override public
focal_class.parameters: (String source)
focal_class.return: Duration
focal_class.signature: Duration convert(String source)
focal_class.class_method_signature: StringToDurationConverter.getUnit(String value)
focal_class.full_signature: private ChronoUnit getUnit(String value)
focal_class.identifier: getUnit
focal_class.modifiers: private
focal_class.parameters: (String value)
focal_class.return: ChronoUnit
focal_class.signature: ChronoUnit getUnit(String value)
focal_method.body: @Override
      public Duration convert(String source) {
          try {
              if (ISO8601.matcher(source).matches()) {
                  return Duration.parse(source);
              }
              Matcher matcher = SIMPLE.matcher(source);
              Assert.state(matcher.matches(), "'" + source + "' is not a valid duration");
              long amount = Long.parseLong(matcher.group(1));
              ChronoUnit unit = getUnit(matcher.group(2));
              return Duration.of(amount, unit);
          } catch (Exception ex) {
              throw new IllegalStateException("'" + source + "' is not a valid duration", ex);
          }
      }
focal_method.class_method_signature: StringToDurationConverter.convert(String source)
focal_method.full_signature: @Override public Duration convert(String source)
focal_method.identifier: convert
focal_method.invocations: matches matcher parse matcher state matches parseLong group getUnit group of
focal_method.modifiers: @Override public
focal_method.parameters: (String source)
focal_method.return: Duration
focal_method.signature: Duration convert(String source)