Skip to content

Commit

Permalink
Add a canned data response to details endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
RustyHMCTS committed Dec 15, 2023
1 parent e4fcc14 commit fd6d90c
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public ResponseEntity<List<DefendantAccountEntity>> 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<AccountDetailsDto> getAccountDetailsByAccountSummary(
@RequestBody AccountSummaryDto accountSummary) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/uk/gov/hmcts/opal/dto/AccountDetailsDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{}",
Expand All @@ -84,7 +84,7 @@ public AccountSearchResultsDto searchDefendantAccounts(AccountSearchDto accountS
}
List<DefendantAccountSummary> summaries = defendantAccountRepository.findByOriginatorNameContaining(
accountSearchDto.getSurname());

return AccountSearchResultsDto.builder()
.searchResults(List.of(AccountSummaryDto.builder().build()))
.totalCount(999)
Expand All @@ -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());

Expand Down
29 changes: 29 additions & 0 deletions src/main/resources/tempDetailsData.json
Original file line number Diff line number Diff line change
@@ -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
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit fd6d90c

Please sign in to comment.