### Question:
ASTConverterValidation implements ASTConverter { public static ASTConverter wrap(ASTConverter converter, Configuration configuration) { String mode = configuration.get("sonar.slang.converter.validation").orElse(null); if (mode == null) { return converter; } else if (mode.equals("throw")) { return new ASTConverterValidation(converter, ValidationMode.THROW_EXCEPTION); } else if (mode.equals("log")) { return new ASTConverterValidation(converter, ValidationMode.LOG_ERROR); } else { throw new IllegalStateException("Unsupported mode: " + mode); } } ASTConverterValidation(ASTConverter wrapped, ValidationMode mode); static ASTConverter wrap(ASTConverter converter, Configuration configuration); @Override Tree parse(String content); @Override void terminate();  }### Answer:
@Test public void wrap() { SimpleConverter wrappedConverter = new SimpleConverter(null); String configKey = "sonar.slang.converter.validation"; assertThat(ASTConverterValidation.wrap(wrappedConverter, new SimpleConfig(configKey, null))).isSameAs(wrappedConverter); ASTConverter converter = ASTConverterValidation.wrap(wrappedConverter, new SimpleConfig(configKey, "throw")); assertThat(converter).isInstanceOf(ASTConverterValidation.class); assertThat(((ASTConverterValidation) converter).mode()).isEqualTo(ValidationMode.THROW_EXCEPTION); converter = ASTConverterValidation.wrap(wrappedConverter, new SimpleConfig(configKey, "log")); assertThat(converter).isInstanceOf(ASTConverterValidation.class); assertThat(((ASTConverterValidation) converter).mode()).isEqualTo(ValidationMode.LOG_ERROR); }
@Test public void wrap_error() { expected.expect(IllegalStateException.class); expected.expectMessage("Unsupported mode: BOOM"); SimpleConverter wrappedConverter = new SimpleConverter(null); String configKey = "sonar.slang.converter.validation"; ASTConverterValidation.wrap(wrappedConverter, new SimpleConfig(configKey, "BOOM")); }