Articles

Java for a lot of time has been accused and mocked for its verbosity. Even the most passionate Java developers have to admit that it felt ridiculous to declare a bean class with two attributes. If you follow the right recommendations, you end up adding not only getters and setters, but also the implementations of toString hashcode and equals methods. The final result is a chunk of boilerplate that invites you to start learning another language. 

Java

 

import java.util.Objects; public class Car { private String brand; private String model; private int year; public String getBrand() { return brand; } public void setBrand(String brand) { this.brand = brand; } public String getModel() { return model; } public void setModel(String model) { this.model = model; } public int getYear() { return year; } public void setYear(int year) { this.year = year; } @Override public String toString() { return "Car{" + "brand='" + brand + ''' + ", model='" + model + ''' + ", year=" + year + '}'; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Car car = (Car) o; return year == car.year && Objects.equals(brand, car.brand) && Objects.equals(model, car.model); } @Override public int hashCode() { return Objects.hash(brand, model, year); }
}

Source de l’article sur DZONE

As a Java Developer, we need to cover a lot of scenarios to ensure the quality of our software and catch bugs as soon as possible when introducing a new code. For 99% of all my use cases AssertJ, Junit, Mockito, and Wiremock are sufficient enough do cover the test cases. But for the other use cases, like unit testing info, debug or warn log messages, these frameworks don’t help you out. There is also no other framework that can provide an easy to use method to capture log messages.

The answer which the community provided works well, but it is a lot of boilerplate code to just assert your log events. Even I faced the same trouble and so I wanted to make it easier for myself and share it with you! So the LogCaptor library came into life.

Source de l’article sur DZONE