Develop the Mock Service
Develop a mock service for saving data in-memory.
We'll cover the following...
add
function
Let’s begin with a simple add
method to the in-memory database. This is based on the Singleton pattern implemented as an enum.
Press + to interact
public enum EmployeeInMemoryDB {INSTANCE;private static List<EmployeeDto> list = new ArrayList<EmployeeDto>();private static Integer lastId = 0;public Integer getId() {return ++lastId;}public void add(EmployeeDto employeeDto) {employeeDto.setId(getId());list.add(employeeDto);}}
Create operation
We will look at the mock service for the ...