Skip to content

Commit

Permalink
Added missing junit tests to ContactService (fetchByPhoneNumber)
Browse files Browse the repository at this point in the history
TODO: save in db incoming sms (they will be useful when calculating stats)
  • Loading branch information
AlessandroArosio committed Apr 13, 2020
1 parent 08d714e commit 9fda376
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import org.springframework.boot.test.context.SpringBootTest;
import org.wicket.calltree.dto.ContactDto;
import org.wicket.calltree.enums.Role;
import org.wicket.calltree.exceptions.ContactException;

import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

/**
* @author Alessandro Arosio - 12/04/2020 09:30
Expand Down Expand Up @@ -42,4 +44,16 @@ void testGetAllTreeUntilRoleLeader_ReturnsAllUntilLeader() {
assertThat(tree).hasSize(2);
assertThat(tree).doesNotContain(reporters.get(0));
}

@Test
void testFetchByPhoneNumber_ReturnsContactDto() {
ContactDto contactDto = contactService.fetchContactByPhoneNumber("+444");

assertEquals("Vlissides", contactDto.getLastName());
}

@Test
void testFetchByPhoneNumber_ContactNotFound_WillThrowException() {
assertThrows(ContactException.class, () -> contactService.fetchContactByPhoneNumber("+00000000000"));
}
}

0 comments on commit 9fda376

Please sign in to comment.