### Question:
ConsignPriceServiceImpl implements ConsignPriceService { @Override public Response createAndModifyPrice(ConsignPrice config, HttpHeaders headers) { ConsignPriceServiceImpl.LOGGER.info("[Consign Price Service][Create New Price Config]"); ConsignPrice originalConfig; if (repository.findByIndex(0) != null) { originalConfig = repository.findByIndex(0); } else { originalConfig = new ConsignPrice(); } originalConfig.setId(config.getId()); originalConfig.setIndex(0); originalConfig.setInitialPrice(config.getInitialPrice()); originalConfig.setInitialWeight(config.getInitialWeight()); originalConfig.setWithinPrice(config.getWithinPrice()); originalConfig.setBeyondPrice(config.getBeyondPrice()); repository.save(originalConfig); return new Response<>(1, success, originalConfig); }  @Override Response getPriceByWeightAndRegion(double weight, boolean isWithinRegion, HttpHeaders headers); @Override Response queryPriceInformation(HttpHeaders headers); @Override Response createAndModifyPrice(ConsignPrice config, HttpHeaders headers); @Override Response getPriceConfig(HttpHeaders headers);  }### Answer:
@Test public void testCreateAndModifyPrice1() { ConsignPrice config = new ConsignPrice(UUID.randomUUID(), 1, 2.0, 3.0, 3.5, 4.0); Mockito.when(repository.findByIndex(0)).thenReturn(config); Mockito.when(repository.save(Mockito.any(ConsignPrice.class))).thenReturn(null); Response result = consignPriceServiceImpl.createAndModifyPrice(config, headers); Assert.assertEquals(new Response<>(1, "Success", config), result); }
@Test public void testCreateAndModifyPrice2() { ConsignPrice config = new ConsignPrice(UUID.randomUUID(), 0, 2.0, 3.0, 3.5, 4.0); Mockito.when(repository.findByIndex(0)).thenReturn(null); Mockito.when(repository.save(Mockito.any(ConsignPrice.class))).thenReturn(null); Response result = consignPriceServiceImpl.createAndModifyPrice(config, headers); Assert.assertEquals(new Response<>(1, "Success", config), result); }