I am trying to write a test case for an API service which deletes a particular record from the database. The test works fine , but i'm not sure what assert statement to add to my test case. As the code changes go through a sonarqube quality gate build , assert statements are mandatory for all unit test cases.
Here is my code:
@Test
public void delete() throws Exception {
List<Fragment> fragments = new ArrayList<>();
fragments.add(fragmentResponse);
when(fragmentRepository.get(anyString())).thenReturn(fragments);
fragmentService.delete("history", "es");
}
As the fragment service returns void, i am unsure about what assert statement to add at the end of it.
You can assert the repository method responsible for deletion is called.
verify(fragmentRepository, times(1)).delete(fragments);