Develop the Mock Service

Develop a mock service for saving data in-memory.

add function

Let’s look at a simple add to the in-memory convention database which is based on the Singleton pattern implemented as an enum.

Press + to interact
public enum EstateInMemoryDB {
INSTANCE;
private static List<EstateDto> list = new ArrayList<EstateDto>();
private static Integer lastId = 0;
public Integer getId() {
return ++lastId;
}
public void add(EstateDto estateDto) {
estateDto.setId(getId());
list.add(estateDto);
}
}

Create operation

We will watch the mock service for the ...