'How to write test cases for Service layer using Junit 4 and mockito

My Repository layer is returning list object, But in my service layer i am filtering out all other and return a single Object. when i try to create test cases it is giving org.mockito.exceptions.misusing.WrongTypeOfReturnValue:

Mockito.when(repository.findByStatus("ACCEPTED", pageRequest)).thenReturn(list);
assertEquals(repository.findByStatus("ACCEPTED", pageRequest), list);

Mockito.when(service.getTmsInstance("ACCEPTED")).thenReturn(instance);
assertEquals(service.getTmsInstance("ACCEPTED"), instance);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source