Grouping multiple repositories with git submodules

A while back I had to make some changes to a couple of existing microservices that were new to me. People would always refer to any of them only by the name of the bounded context that they were a part of: the Message Center. 

Not sure where to find the repositories, I searched for message center in gitlab thinking there should be a project, folder, repo, or something like that. But alas, I was unable to find anything.

Continue reading “Grouping multiple repositories with git submodules”

Unit testing HTTP calls with LocalTestServer

There are times when you’re unit testing code that is making HTTP calls to a remote server. You could be using a library such as Apache’sHttpClient or Spring’s RestTemplate to do so.

Of course, you don’t want to rely on a remote service for your unit tests. Besides the overhead involved (remember that unit test are supposed to be fast) you simply cannot rely on remote services being available during execution of your tests. You probably are also not able to completely control the response for all of your test scenarios.
Continue reading “Unit testing HTTP calls with LocalTestServer”

Custom Boolean User Type with Hibernate JPA

The ANSI SQL 1999 standard introduced a BOOLEAN data type (although unfortunately only as an optional feature). But to date it still isn’t implemented by most major database systems. As a consequence boolean columns are implemented in various ways. E.g., CHAR columns containing ‘Y’ or ‘N’, or using BIT columns. Subsequently, there is no way for JPA to provide a standardized way of mapping an entity’s boolean fields onto database columns.

Hibernate offers a custom YesNoType for boolean implementations using CHAR(1) columns containing ‘Y’ or ’N’ characters. But for other practices you basically have to provide your own solution. Fortunately, Hibernate offers the possibility of creating your own custom UserType’s. In this blog entry I will give an example of one such custom Boolean UserType. Continue reading “Custom Boolean User Type with Hibernate JPA”

Logging JAX-WS SOAP messages in Spring

Whenever you’re using JAX-WS within Spring you’ll probably want to log the incoming and outgoing SOAP messages – if only for debugging during development. So the first thing to do is increase the log levels, right? Unfortunately this will have no effect. What you will have to do is to make use of the javax.xml.ws.handler.HandlerResolver interface. So how do we do this?
Continue reading “Logging JAX-WS SOAP messages in Spring”

Documenting Spring RESTful APIs

Lately, I’ve been writing alot of RESTful services using the Spring framework and its @RestController. The only thing I really missed was an easy way to document the RESTful API. I’ve looked into various options, and like most people, I found that Swagger seemed to be the only viable option. However, after having tried it, I found some serious issues. Besides being a very bulky dependency to have to include, having a visually attractive but very cluttered front-end in the form of SwaggerUI, what I disliked the most was the pollution of my code with alot of additional annotations.
Continue reading “Documenting Spring RESTful APIs”

Implementing Domain-Driven Design book review

For the last year or so, I’ve been struggling with what Martin Fowler calls the Anemic Domain Model. The development teams at one of my clients, employ Java in a fashion where OO concepts are sometimes hard to find. Java objects are used as mere dataholders and business logic is scattered all around the place but mostly concentrated inside stored procedures. It also doesn’t help that alot of frameworks and libraries used nowadays, such as JPA/hibernate, Jackson, etc., rely heavily on the JavaBeans specifications thereby inadvertently encouraging the Anemic Domain Model anti-pattern.

Continue reading “Implementing Domain-Driven Design book review”