### Question:
SecurityServiceImpl implements SecurityService { @Override public Response addNewSecurityConfig(SecurityConfig info, HttpHeaders headers) { SecurityConfig sc = securityRepository.findByName(info.getName()); if (sc != null) { return new Response<>(0, "Security Config Already Exist", null); } else { SecurityConfig config = new SecurityConfig(); config.setId(UUID.randomUUID()); config.setName(info.getName()); config.setValue(info.getValue()); config.setDescription(info.getDescription()); securityRepository.save(config); return new Response<>(1, success, config); } }  @Override Response findAllSecurityConfig(HttpHeaders headers); @Override Response addNewSecurityConfig(SecurityConfig info, HttpHeaders headers); @Override Response modifySecurityConfig(SecurityConfig info, HttpHeaders headers); @Override Response deleteSecurityConfig(String id, HttpHeaders headers); @Override Response check(String accountId, HttpHeaders headers);  }### Answer:
@Test public void testAddNewSecurityConfig1() { SecurityConfig sc = new SecurityConfig(); Mockito.when(securityRepository.findByName(Mockito.anyString())).thenReturn(sc); Response result = securityServiceImpl.addNewSecurityConfig(sc, headers); Assert.assertEquals(new Response<>(0, "Security Config Already Exist", null), result); }
@Test public void testAddNewSecurityConfig2() { SecurityConfig sc = new SecurityConfig(); Mockito.when(securityRepository.findByName(Mockito.anyString())).thenReturn(null); Mockito.when(securityRepository.save(Mockito.any(SecurityConfig.class))).thenReturn(null); Response result = securityServiceImpl.addNewSecurityConfig(sc, headers); Assert.assertEquals("Success", result.getMsg()); }