In a distributed applications, it's critical to build a fault-tolerant system

Resiliency is — ability of component to recover and continue its operation in case of failure

In monolith architecture, a single point of failure brings down the entire application, but in a microservice architecture, each application depends on many small-small applications. A single point for failure won't bring down the entire application.

This doesn’t mean that microservice architecture is resilient, but it has its own challenge and those are mission-critical.

Resiliency in the event-based system on Apache Kafka

Consider the simple scenario — Application A consumes event from Kafka Topic and makes rest call to downstream Application…

In test-driven development, it's always a requirement to mimic actual behaviour — objects which are not real but behave like it. That's where Test Double helps us out.

Test Double is any object used instead of a real object for testing purpose(like a stunt double in movies)

Before diving into types of double & other things, let’s first understand the fundamentals of the test.

Unit is the smallest testable part of the software. This can be one class or one method or one functionality. Object-under-test or System-under-test termed as SUT, its supporting objects are called as Collaborators

Every test should follow this golden rule AAA — Arrange, Act and Assert.

In the arrange section you will set-up things which…

Spring HATEOAS ships with varites of base representation models

  • Resource — an item resource, wrapper around DTO and entities which captures single item & enrich it with links
  • Resources — a collection of Resource
  • PagedResources — an extenstion of Resources with additional information like number of pages, navigation link etc.

In last article, we have seen basic of spring hateoas. In this we will see how paging & sorting works with HATEOAS.

There are two ways we can achieve this

  1. Using @RestResource annotation — useful when domain objects are directly exposed in rest-api
  2. Using ResourceAssembler- useful when some transfer objects…

Spring HATEOAS is library project which can be used to create REST representation that follows HATEOS principle

What is HATEOAS?

HATEOS stands for Hypermedia As The Engine Of Application State.

This allsows better understand of API without providing any specific documention to client. This is done by adding links in returned response and use that links to do further communication to server. This avoid breaking of client due to change in service implementation.HATEOAS is fundamental concept to create Discoverable REST APIs.

Spring boot Dependency

Need to add below dependency to get spring hateoas support


spring-boot-starter-hateoas contains spring-boot-starter-webso you do not need to include that.



Mockito comes with different annotation, out of them most used are below with their usage

1. @Mock :

Mock annotation is used to create Mocked instance. This are not real objects, rather created mock for class. @Mock annotation is same as Mockito.mock(class)

public class MockTest {

private List<String> list = new ArrayList<>();

public void testMock(){

//calling method on mock object, do nothing
public void testMockWithStub() {
//try stubbing a method
String expected = "Mock String";
Mockito.when(list.get(0)).thenReturn(expected); Assert.assertEquals(expected, list.get(0));

2 @Spy :

Spy annotation is used to create real object and spy on that real object. With Spy…

CAP Theorem also called as Brewer’s theorem.

It is impossible for a distributed data stroe to simultaneouslt provide more than tow out of following three guarantees

  • Consistency:Every read recevies the most recent wirte or an error
  • Availabiliy: Every request received a (non-error) response, without the gurateee that it contains the most recent write
  • Partition Tolernace : The system continues to operate despite an arbitarary number of messages being dropped.

In case of network failure,

  • Cancel the operation — decrease the avaiability but ensure consistency
  • Proceed with the operation — provide availability but risk inconsistency

So in case of network parition…


Traveller, Explorer, Curious to learn new things

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store