diff --git a/src/main/java/uk/gov/hmcts/opal/controllers/DefendantAccountController.java b/src/main/java/uk/gov/hmcts/opal/controllers/DefendantAccountController.java index 43c1df7bd..b1b88e17f 100644 --- a/src/main/java/uk/gov/hmcts/opal/controllers/DefendantAccountController.java +++ b/src/main/java/uk/gov/hmcts/opal/controllers/DefendantAccountController.java @@ -77,7 +77,7 @@ public ResponseEntity> getDefendantAccountsByBusine return ResponseEntity.ok(response); } - @GetMapping(value = "/details") + @GetMapping(value = "/details", consumes = MediaType.APPLICATION_JSON_VALUE) @Operation(summary = "Get defendant account details by providing the defendant account summary") public ResponseEntity getAccountDetailsByAccountSummary( @RequestBody AccountSummaryDto accountSummary) { diff --git a/src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java b/src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java index 9e790dda8..f4fc971c8 100644 --- a/src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java +++ b/src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java @@ -2,17 +2,17 @@ import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.Data; import lombok.NoArgsConstructor; -import lombok.extern.jackson.Jacksonized; import java.math.BigDecimal; import java.time.LocalDate; import java.util.List; +@Data @Builder @NoArgsConstructor @AllArgsConstructor -@Jacksonized public class AccountDetailsDto implements ToJsonString { //defendant_accounts.account_number diff --git a/src/main/java/uk/gov/hmcts/opal/service/DefendantAccountService.java b/src/main/java/uk/gov/hmcts/opal/service/DefendantAccountService.java index ee16779e5..f0cf7d1df 100644 --- a/src/main/java/uk/gov/hmcts/opal/service/DefendantAccountService.java +++ b/src/main/java/uk/gov/hmcts/opal/service/DefendantAccountService.java @@ -72,7 +72,7 @@ public AccountSearchResultsDto searchDefendantAccounts(AccountSearchDto accountS if ("test".equalsIgnoreCase(accountSearchDto.getCourt())) { try (InputStream in = Thread.currentThread().getContextClassLoader() - .getResourceAsStream("tempData.json")) { + .getResourceAsStream("tempSearchData.json")) { ObjectMapper mapper = newObjectMapper(); AccountSearchResultsDto dto = mapper.readValue(in, AccountSearchResultsDto.class); log.info(":searchDefendantAccounts: temporary Hack for Front End testing. Read JSON file: \n{}", @@ -84,7 +84,7 @@ public AccountSearchResultsDto searchDefendantAccounts(AccountSearchDto accountS } List summaries = defendantAccountRepository.findByOriginatorNameContaining( accountSearchDto.getSurname()); - + return AccountSearchResultsDto.builder() .searchResults(List.of(AccountSummaryDto.builder().build())) .totalCount(999) @@ -94,6 +94,24 @@ public AccountSearchResultsDto searchDefendantAccounts(AccountSearchDto accountS public AccountDetailsDto getAccountDetailsByAccountSummary(AccountSummaryDto accountSummary) { + + if ("test".equalsIgnoreCase(accountSummary.getCourt())) { + + + try (InputStream in = Thread.currentThread().getContextClassLoader() + .getResourceAsStream("tempDetailsData.json")) { + + ObjectMapper mapper = newObjectMapper(); + AccountDetailsDto dto = mapper.readValue(in, AccountDetailsDto.class); + log.info( + ":getAccountDetailsByAccountSummary: temporary Hack for Front End testing. Read JSON file: \n{}", + dto.toPrettyJsonString()); + return dto; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + //split name into parts for db query final String[] nameParts = NamesUtil.splitFullName(accountSummary.getName()); diff --git a/src/main/resources/tempDetailsData.json b/src/main/resources/tempDetailsData.json new file mode 100644 index 000000000..80e326614 --- /dev/null +++ b/src/main/resources/tempDetailsData.json @@ -0,0 +1,29 @@ +{ + "accountNumber": "123456789", + "fullName": "Mr John K Doe", + "accountCT": "Greater London", + "accountType": "Defendant", + "address": "123 Main Street, Reading, Berkshire", + "postCode": "RG12 0AA", + "dob": [1966, 12 , 1], + "detailsChanged": [2020, 11 , 1], + "lastCourtAppAndCourtCode": "20/09/1990 01", + "lastMovement": [2022, 11 , 1], + "commentField": ["Comment 1", "Comment 2"], + "pcr": "PC123456", + "documentLanguage": "English", + "hearingLanguage": "English", + "paymentDetails": "1000/month", + "lumpSum": 500.00, + "commencing": [2021, 9 , 1], + "daysInDefault": 30, + "sentencedDate": [2020, 12 , 21], + "lastEnforcement": "lastEn", + "override": "123456", + "enforcer": 1, + "enforcementCourt": 456, + "imposed": 2000.00, + "amountPaid": 1000.00, + "arrears": 500.00, + "balance": 500.00 +} diff --git a/src/main/resources/tempData.json b/src/main/resources/tempSearchData.json similarity index 100% rename from src/main/resources/tempData.json rename to src/main/resources/tempSearchData.json diff --git a/src/test/java/uk/gov/hmcts/opal/service/DefendantAccountServiceTest.java b/src/test/java/uk/gov/hmcts/opal/service/DefendantAccountServiceTest.java index 9d708e3af..b99890b61 100644 --- a/src/test/java/uk/gov/hmcts/opal/service/DefendantAccountServiceTest.java +++ b/src/test/java/uk/gov/hmcts/opal/service/DefendantAccountServiceTest.java @@ -189,6 +189,12 @@ void testGetAccountDetailsByAccountSummaryTemporary() { defendantAccountService.getAccountDetailsByAccountSummary(constructTestAccountSummaryDto(LocalDate.now())); } + @Test + void testGetAccountDetailsByAccountSummaryTemporary2() { + var testAccountSummary = AccountSummaryDto.builder().court("test").build(); + defendantAccountService.getAccountDetailsByAccountSummary(testAccountSummary); + } + private AccountSummaryDto constructTestAccountSummaryDto(final LocalDate today) { return AccountSummaryDto.builder() .accountNo("accountNameNo")