JUnit Hamcrest: Matching a Group of Map Properties from Any Map within a List

Let’s say that you have an ArrayList of LinkedHashMaps. Let’s further say that you would like to find any Map within that List, which contains a set of Properties. Here is how you can write a Unit Test with Hamcrest Matchers to do this: Here we can see that we…

Continue reading

Handling Multiple Date Formats with One Method via Joda Time

Handling Multiple Date Formats with One Method via Joda Time

Nearly any project that amounts to anything must handle the processing of Dates, Times, and Timestamps. When it comes to Java projects, I see time and time again that developers just insert date formatters anywhere and everywhere. This violates the concept of modularity and making a segment of code do…

Continue reading

Code Analysis with Java and AngularJS Project via SonarQube

Code Analysis with Java and AngularJS Project via SonarQube

Many Java based projects are shifting away from more traditional Java based frontend technologies, such as JSP, JSF, and GWT. Today, they are moving to Single Page Application technologies like AngularJS. This leaves Java as the language for the backend. As a result, you will likely experience a project using…

Continue reading

Spring Boot, Spring Data REST and Query Parameters

I have Spring Data REST repository that takes query parameters. It uses a PagingAndSortingRepository and looks like this: [code language=”java”] @RepositoryRestResource @CrossOrigin(origins = "http://localhost:8000") public interface IRestaurantRepository extends PagingAndSortingRepository<Restaurant, Long> { public Page<Restaurant> findByNameContaining(String name, Pageable pageable); } [/code] You would get an error if you were to execute the…

Continue reading