Develop the Mock Service

Develop a mock service for saving data in-memory.

add function

Let’s start with a simple add to the in-memory custom database, which is based on the Singleton pattern implemented as an enum.

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

Create operation

We will be looking at the mock service ...