-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jamie Briggs <[email protected]>
- Loading branch information
1 parent
e313964
commit 470a098
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
data-service/src/test/java/uk/gov/laa/ccms/data/service/CaseSearchServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package uk.gov.laa.ccms.data.service; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.data.domain.PageImpl; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.domain.Specification; | ||
import uk.gov.laa.ccms.data.entity.CaseSearch; | ||
import uk.gov.laa.ccms.data.mapper.CaseSearchMapperImpl; | ||
import uk.gov.laa.ccms.data.model.CaseDetails; | ||
import uk.gov.laa.ccms.data.repository.CaseSearchRepository; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
@DisplayName("Case search service test") | ||
class CaseSearchServiceTest { | ||
|
||
@Mock | ||
private CaseSearchRepository caseSearchRepository; | ||
|
||
private CaseSearchService caseSearchService; | ||
|
||
@BeforeEach | ||
void setup(){ | ||
caseSearchService = new CaseSearchService(caseSearchRepository, new CaseSearchMapperImpl()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Should return CaseSummary object") | ||
void shouldReturnCaseSummaryObject(){ | ||
// Given | ||
new CaseSearch(); | ||
when(caseSearchRepository.findAll(any(Specification.class), | ||
any(Pageable.class))).thenReturn(new PageImpl<>(List.of( | ||
CaseSearch.builder().lscCaseReference("123").build()))); | ||
// When | ||
Optional<CaseDetails> cases = caseSearchService.getCases("123", | ||
"345", | ||
"ACT", | ||
"Surame", | ||
1L, | ||
2L, | ||
PageRequest.of(1, 10)); | ||
// Then | ||
assertTrue(cases.isPresent()); | ||
assertEquals("123", cases.get().getContent().getFirst().getCaseReferenceNumber()); | ||
} | ||
|
||
} |