Building a REST client with Spray

In a previous blog I wrote how to make an API. See here.

Now we’ll make a client to use that API. This can be done with spray-client.

First we add dependencies for spray-client and spray-json:

This is what the main class looks like:

You can get the whole code from github.

Code Challenge “Vrolijke Framboos” Postmortem

Tuesday we had our second ever “Vrolijke Framboos” (Dutch for Happy Raspberry)
Java code challenge at JDriven and it was a blast! This year’s
challenge was to create a REST service client that would play a number guessing
game with the server. After setting up a session you would guess a number and the
server would respond with either “lower”, “higher” or “bingo”. The goal was to guess
as many numbers in the two minutes you’d be given. Given the name of the challenge
you can probably guess that the target platform would be a
Raspberry Pi!

It was an incredible and fun experience and in this post I want to explain how I
approached the challenge and how my solution ended up in the second place, making
me just miss the opportunity to take home the trophy and a new Raspberry.

Continue reading

Unit testing an AngularJS directive’s private functions.

As we all know Javascript gives us the awesome ability to create functions inside functions. This allows us to create private functions which support the main function. It is also something we do often when creating object functions. This structure is used by angular for the creation of providers and directives alike.

Every once in a while I personally come to a point where I would like to test these private functions. This is especially true for use cases in Angular such as directives. Continue reading