### Question:
PaymentServiceImpl implements PaymentService { @Override public Response query(HttpHeaders headers){ List<Payment> payments = paymentRepository.findAll(); if(payments!= null && !payments.isEmpty()){ return new Response<>(1,"Query Success", payments); }else { return new Response<>(0, "No Content", null); } }  @Override Response pay(Payment info, HttpHeaders headers); @Override Response addMoney(Payment info, HttpHeaders headers); @Override Response query(HttpHeaders headers); @Override void initPayment(Payment payment, HttpHeaders headers);  }### Answer:
@Test public void testQuery1() { List<Payment> payments = new ArrayList<>(); payments.add(new Payment()); Mockito.when(paymentRepository.findAll()).thenReturn(payments); Response result = paymentServiceImpl.query(headers); Assert.assertEquals(new Response<>(1,"Query Success", payments), result); }
@Test public void testQuery2() { Mockito.when(paymentRepository.findAll()).thenReturn(null); Response result = paymentServiceImpl.query(headers); Assert.assertEquals(new Response<>(0, "No Content", null), result); }