diff options
author | Ina Curdt | 2020-05-06 11:17:09 +0000 |
---|---|---|
committer | Ina Curdt | 2020-05-06 11:17:09 +0000 |
commit | 3c335dd5029ebb24ff6616d4c115b286c2d6503e (patch) | |
tree | 57061c1b377c189f121566561bc05624cae33f00 | |
parent | f1f8152d480fd76c2f859b5b4a5cd151849c08e8 (diff) | |
download | backup.org.eclipse.openk-coremodules.contactBaseData.backend-SI-295_Guppen_Verteiler_anlegen.tar.gz backup.org.eclipse.openk-coremodules.contactBaseData.backend-SI-295_Guppen_Verteiler_anlegen.tar.xz backup.org.eclipse.openk-coremodules.contactBaseData.backend-SI-295_Guppen_Verteiler_anlegen.zip |
SI-879 UnitTestsHEADmasterSI-295_Guppen_Verteiler_anlegenDEVELOP
-rw-r--r-- | src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java | 13 | ||||
-rw-r--r-- | src/test/java/org/eclipse/openk/contactbasedata/service/ContactServiceTest.java | 12 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java b/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java index 86db98c..d0e9300 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/controller/ContactControllerTest.java @@ -30,6 +30,8 @@ import org.springframework.http.MediaType; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.web.servlet.MockMvc; +import java.util.UUID; + import static org.hamcrest.Matchers.is; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.when; @@ -61,4 +63,15 @@ public class ContactControllerTest { .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("totalElements", is(2))); } + + @Test + public void shouldReturnSingleContactByUuid() throws Exception { + VwDetailedContact vwDetailedContact = MockDataHelper.mockVDetailedContact(); + + when(contactService.findDetailedContactByUuid(any(UUID.class))).thenReturn(vwDetailedContact); + + mockMvc.perform(get("/contacts/{uuid}", UUID.randomUUID())) + .andExpect(status().is2xxSuccessful()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)); + } }
\ No newline at end of file diff --git a/src/test/java/org/eclipse/openk/contactbasedata/service/ContactServiceTest.java b/src/test/java/org/eclipse/openk/contactbasedata/service/ContactServiceTest.java index b26b72b..c8d9cb4 100644 --- a/src/test/java/org/eclipse/openk/contactbasedata/service/ContactServiceTest.java +++ b/src/test/java/org/eclipse/openk/contactbasedata/service/ContactServiceTest.java @@ -30,6 +30,8 @@ import org.springframework.data.domain.Pageable; import org.springframework.test.context.ContextConfiguration; import java.util.Date; +import java.util.Optional; +import java.util.UUID; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.*; @@ -58,4 +60,14 @@ public class ContactServiceTest { assertEquals(mockPaged.getTotalElements(), retPage.getTotalElements()); } + + @Test + public void shouldFindSingleDetailedContactProperly() { + VwDetailedContact mockContact = MockDataHelper.mockVDetailedContact(); + when(detailedContactRepository.findByUuid(any(UUID.class))).thenReturn(Optional.of(mockContact)); + + VwDetailedContact detailedContact = contactService.findDetailedContactByUuid(UUID.randomUUID()); + + assertEquals(detailedContact.getUuid(), mockContact.getUuid()); + } } |