Remove logback dependency
- Id
- 6fbbeaf8ce3513484340382d05516be22c290b6b
- Author
- Caio
- Commit time
- 2019-06-03T09:50:35+02:00
Modified pom.xml
</dependency>
<dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- </dependency>
-
- <dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
Modified src/test/java/co/caio/cerberus/Util.java
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Optional;
import java.util.Properties;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class Util {
-
- private static final Logger logger = LoggerFactory.getLogger(Util.class);
-
private static final ObjectMapper mapper;
static {
var samplesStream = Util.class.getResourceAsStream("/sample_recipes.jsonlines");
var reader = new BufferedReader(new InputStreamReader(samplesStream));
try {
- return reader.lines().map(Util::readRecipe).flatMap(Optional::stream);
- } catch (Exception e) {
- throw new RuntimeException(e);
+ return reader.lines().map(Util::readRecipe);
+ } catch (Exception wrapped) {
+ throw new RuntimeException(wrapped);
}
}
- private static Optional<Recipe> readRecipe(String line) {
+ private static Recipe readRecipe(String line) {
try {
- return Optional.of(mapper.readValue(line, Recipe.class));
- } catch (Exception logged) {
- logger.warn("Failed reading recipe from string: " + line, logged);
- return Optional.empty();
+ return mapper.readValue(line, Recipe.class);
+ } catch (Exception wrapped) {
+ throw new RuntimeException(wrapped);
}
}
try {
indexer.addRecipe(recipe);
tmpRecipeMap.put(recipe.recipeId(), recipe);
- } catch (Exception logged) {
- logger.error(String.format("Failed to index recipe %s", recipe), logged);
+ } catch (Exception wrapped) {
+ throw new RuntimeException(wrapped);
}
});
try {