### Question:
ContactsServiceImpl implements ContactsService { @Override public Response create(Contacts addContacts, HttpHeaders headers) { Contacts contacts = new Contacts(); contacts.setId(UUID.randomUUID()); contacts.setName(addContacts.getName()); contacts.setPhoneNumber(addContacts.getPhoneNumber()); contacts.setDocumentNumber(addContacts.getDocumentNumber()); contacts.setAccountId(addContacts.getAccountId()); contacts.setDocumentType(addContacts.getDocumentType()); ArrayList<Contacts> accountContacts = contactsRepository.findByAccountId(addContacts.getAccountId()); if (accountContacts.contains(contacts)) { ContactsServiceImpl.LOGGER.info("[Contacts-Add&Delete-Service][AddContacts] Fail.Contacts already exists"); return new Response<>(0, "Contacts already exists", null); } else { contactsRepository.save(contacts); ContactsServiceImpl.LOGGER.info("[Contacts-Add&Delete-Service][AddContacts] Success."); return new Response<>(1, "Create contacts success", contacts); } }  @Override Response findContactsById(UUID id, HttpHeaders headers); @Override Response findContactsByAccountId(UUID accountId, HttpHeaders headers); @Override Response createContacts(Contacts contacts, HttpHeaders headers); @Override Response create(Contacts addContacts, HttpHeaders headers); @Override Response delete(UUID contactsId, HttpHeaders headers); @Override Response modify(Contacts contacts, HttpHeaders headers); @Override Response getAllContacts(HttpHeaders headers);  }### Answer:
@Test public void testCreate1() { Contacts addContacts = new Contacts(UUID.randomUUID(), UUID.randomUUID(), "name", 1, "12", "10001"); ArrayList<Contacts> accountContacts = new ArrayList<>(); accountContacts.add(addContacts); Mockito.when(contactsRepository.findByAccountId(Mockito.any(UUID.class))).thenReturn(accountContacts); Response result = contactsServiceImpl.create(addContacts, headers); Assert.assertEquals(new Response<>(0, "Contacts already exists", null), result); }
@Test public void testCreate2() { Contacts addContacts = new Contacts(UUID.randomUUID(), UUID.randomUUID(), "name", 1, "12", "10001"); ArrayList<Contacts> accountContacts = new ArrayList<>(); Mockito.when(contactsRepository.findByAccountId(Mockito.any(UUID.class))).thenReturn(accountContacts); Mockito.when(contactsRepository.save(Mockito.any(Contacts.class))).thenReturn(null); Response result = contactsServiceImpl.create(addContacts, headers); Assert.assertEquals(new Response<>(1, "Create contacts success", addContacts), result); }