### Question:
AssuranceServiceImpl implements AssuranceService { @Override public Response modify(String assuranceId, String orderId, int typeIndex, HttpHeaders headers) { Response oldAssuranceResponse = findAssuranceById(UUID.fromString(assuranceId), headers); Assurance oldAssurance = (Assurance) oldAssuranceResponse.getData(); if (oldAssurance == null) { AssuranceServiceImpl.LOGGER.info("[Assurance-Modify-Service][ModifyAssurance] Fail.Assurance not found."); return new Response<>(0, "Fail.Assurance not found.", null); } else { AssuranceType at = AssuranceType.getTypeByIndex(typeIndex); if (at != null) { oldAssurance.setType(at); assuranceRepository.save(oldAssurance); AssuranceServiceImpl.LOGGER.info("[Assurance-Modify-Service][ModifyAssurance] Success."); return new Response<>(1, "Modify Success", oldAssurance); } else { AssuranceServiceImpl.LOGGER.info("[Assurance-Modify-Service][ModifyAssurance] Fail.Assurance Type not exist."); return new Response<>(0, "Assurance Type not exist", 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 testModify2() { UUID assuranceId = UUID.randomUUID(); Assurance assurance = new Assurance(null, null, null); Mockito.when(assuranceRepository.findById(assuranceId)).thenReturn(assurance); Mockito.when(assuranceRepository.save(assurance)).thenReturn(null); Response result = assuranceServiceImpl.modify(assuranceId.toString(), "orderId", 1, headers); Assert.assertEquals(new Response<>(1, "Modify Success", new Assurance(null, null, AssuranceType.TRAFFIC_ACCIDENT)), result); }
@Test public void testModify3() { UUID assuranceId = UUID.randomUUID(); Assurance assurance = new Assurance(null, null, null); Mockito.when(assuranceRepository.findById(assuranceId)).thenReturn(assurance); Mockito.when(assuranceRepository.save(assurance)).thenReturn(null); Response result = assuranceServiceImpl.modify(assuranceId.toString(), "orderId", 0, headers); Assert.assertEquals(new Response<>(0, "Assurance Type not exist", null), result); }