### Question:
AssuranceServiceImpl implements AssuranceService { @Override public Response getAllAssurances(HttpHeaders headers) { List<Assurance> as = assuranceRepository.findAll(); if (as != null && !as.isEmpty()) { ArrayList<PlainAssurance> result = new ArrayList<>(); for (Assurance a : as) { PlainAssurance pa = new PlainAssurance(); pa.setId(a.getId()); pa.setOrderId(a.getOrderId()); pa.setTypeIndex(a.getType().getIndex()); pa.setTypeName(a.getType().getName()); pa.setTypePrice(a.getType().getPrice()); result.add(pa); } return new Response<>(1, "Success", result); } else { return new Response<>(0, "No Content, Assurance is empty", null); } }  @Override Response findAssuranceById(UUID id, HttpHeaders headers); @Override Response findAssuranceByOrderId(UUID orderId, HttpHeaders headers); @Override Response create(int typeIndex, String orderId, HttpHeaders headers); @Override Response deleteById(UUID assuranceId, HttpHeaders headers); @Override Response deleteByOrderId(UUID orderId, HttpHeaders headers); @Override Response modify(String assuranceId, String orderId, int typeIndex, HttpHeaders headers); @Override Response getAllAssurances(HttpHeaders headers); @Override Response getAllAssuranceTypes(HttpHeaders headers);  }### Answer:
@Test public void testGetAllAssurances1() { ArrayList<Assurance> assuranceList = new ArrayList<>(); assuranceList.add(new Assurance(null, null, AssuranceType.TRAFFIC_ACCIDENT)); ArrayList<PlainAssurance> plainAssuranceList = new ArrayList<>(); plainAssuranceList.add(new PlainAssurance(null, null, 1, "Traffic Accident Assurance", 3.0)); Mockito.when(assuranceRepository.findAll()).thenReturn(assuranceList); Response result = assuranceServiceImpl.getAllAssurances(headers); Assert.assertEquals(new Response<>(1, "Success", plainAssuranceList), result); }
@Test public void testGetAllAssurances2() { Mockito.when(assuranceRepository.findAll()).thenReturn(null); Response result = assuranceServiceImpl.getAllAssurances(headers); Assert.assertEquals(new Response<>(0, "No Content, Assurance is empty", null), result); }