JUnit 5 Tricks Recap
JUnit: Lay of the Land & Mutation testing
Alright, what do we know about unit tests?
- A unit test verifies an individual unit of code works as expected,
- It is small, fast and isolate a single functionality
They are generally named based on what the test verifies, e.g. testInvalidAccountIdThrowsException
; they are independent
from each other even though grouped in the
same class as related tests.
We create them in the same package structure as the source code but under the src/test/java
directory. With Maven,
tests can be run using lifecycle phases like test
, install
, etc.
Bron to Clique
Discovery of Bron-Kerbosch in AoC24-23
For part 2 of this challenge, I am actually ashamed of showing here what I initially tried to program without knowing what a clique was, nor that an algorithm existed to find the maximal cliques in a graph… Maybe one day when I add a Premium Pass to this blog, a few privileged users could see the pépite.
Part 1 - the piece of 🍰
As The Historians wander around a secure area at Easter Bunny HQ, you come across posters for a LAN party scheduled for today!
Maybe you can find it; you connect to a nearby datalink port and download a map of the local network (your puzzle input).
The network map provides a list of every connection between two computers. For example:
kh-tc
qp-kh
de-cg
ka-co
Each line of text in the network map represents a single connection; the line kh-tc represents a connection between the
computer named kh and the computer named tc. Connections aren't directional; tc-kh would mean exactly the same thing.
LAN parties typically involve multiplayer games, so maybe you can locate it by finding groups of connected computers.
Start by looking for sets of three computers where each computer in the set is connected to the other two computers.
If the Chief Historian is here, and he's at the LAN party, it would be best to know that right away. You're pretty
sure his computer's name starts with t, so consider only sets of three computers where at least one computer's name
starts with t. That narrows the list down to 7 sets of three inter-connected computers:
co,de,ta
co,ka,ta
de,ka,ta
qp,td,wh
tb,vc,wq
tc,td,wh
td,wh,yn
Find all the sets of three inter-connected computers. How many contain at least one computer with a name that starts
with t?
Initial Thoughts
Setting the “starts with t” requirement aside, the list of computers given is a list of edges connecting two computers (nodes).
We all need a Holiday Destination Finder
Tiptoeing Through the Asynch Door with the CompletionStage Interface JSE17
When it comes to holidays, I’m as spontaneous as they come. I enjoy not planning and picking the best option available just before or even while traveling.
So I needed a holiday… and a reason to explore Java’s async magic.
We’ll get to this Holiday Finder but first let’s get the theory out of the way, shall we?
Diving Right In
Considering two API calls A & B, API A is called first, and then API B. This is what synchronous code does: it waits before executing the next task and things run in order. However, could the thread blocked on the API response be doing some other work instead?