Skip to content

Commit

Permalink
code tidy and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TomReed committed Aug 12, 2024
1 parent 64d3045 commit 2ef49ca
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
@RequestMapping("/api/create-fine-accounts")
@Slf4j(topic = "CreateFineAccountController")
@Tag(name = "Create Fine Account Controller")
public class CreateFineAccountController {
public class CreateFineAccountsController {

@PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<OpalS2SResponseWrapper> searchDebtorProfile(OpalS2SRequestWrapper createFineAccountsRequest) {
public ResponseEntity<OpalS2SResponseWrapper> createFineAccounts(OpalS2SRequestWrapper createFineAccountsRequest) {

log.info(":POST:searchDebtorProfile: request: \n{}", createFineAccountsRequest);
log.info(":POST:createFineAccounts: request: \n{}", createFineAccountsRequest);
OpalS2SResponseWrapper response = OpalS2SResponseWrapper.builder()
.opalResponsePayload(responseXML)
.errorDetail("")
.build();
return new ResponseEntity<>(response, HttpStatus.OK);
}
Expand All @@ -34,13 +33,12 @@ public ResponseEntity<OpalS2SResponseWrapper> searchDebtorProfile(OpalS2SRequest
xmlns="http://www.justice.gov.uk/magistrates/atcm/CreateFineAccountsResponse"
xmlns:lg="http://www.justice.gov.uk/magistrates/atcm/CreatedFineAccount">
<lg:CreatedFineAccount>
<AccountID>12345</AccountID>
<FineAmount>100.00</FineAmount>
<DueDate>2024-09-01</DueDate>
<CPPID xmlns="">12345</CPPID>
<CPPUUID xmlns="">12345</CPPUUID>
</lg:CreatedFineAccount>
<NumberOfFineAccounts>1</NumberOfFineAccounts>
<ErrorCode></ErrorCode>
<ErrorMessage></ErrorMessage>
<NumberOfFineAccounts xmlns="">1</NumberOfFineAccounts>
<ErrorCode xmlns=""></ErrorCode>
<ErrorMessage xmlns=""></ErrorMessage>
</CreateFineAccountsResponse>
""";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public ResponseEntity<OpalS2SResponseWrapper> searchDebtorProfile(OpalS2SRequest
log.info(":POST:searchDebtorProfile: request: \n{}", debtorProfileRequest);
OpalS2SResponseWrapper response = OpalS2SResponseWrapper.builder()
.opalResponsePayload(responseXML)
.errorDetail("")
.build();
return new ResponseEntity<>(response, HttpStatus.OK);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package uk.gov.hmcts.opal.controllers;

import org.junit.jupiter.api.Test;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import uk.gov.hmcts.opal.dto.OpalS2SRequestWrapper;
import uk.gov.hmcts.opal.dto.OpalS2SResponseWrapper;

import static org.junit.jupiter.api.Assertions.assertEquals;


class CreateFineAccountsControllerTest {

private CreateFineAccountsController createFineAccountsController = new CreateFineAccountsController();

@Test
void testSearchDebtorProfile_Success() {
// Arrange
OpalS2SRequestWrapper request = new OpalS2SRequestWrapper();
OpalS2SResponseWrapper response = OpalS2SResponseWrapper.builder()
.opalResponsePayload("""
<?xml version="1.0" encoding="UTF-8"?>
<CreateFineAccountsResponse
xmlns="http://www.justice.gov.uk/magistrates/atcm/CreateFineAccountsResponse"
xmlns:lg="http://www.justice.gov.uk/magistrates/atcm/CreatedFineAccount">
<lg:CreatedFineAccount>
<CPPID xmlns="">12345</CPPID>
<CPPUUID xmlns="">12345</CPPUUID>
</lg:CreatedFineAccount>
<NumberOfFineAccounts xmlns="">1</NumberOfFineAccounts>
<ErrorCode xmlns=""></ErrorCode>
<ErrorMessage xmlns=""></ErrorMessage>
</CreateFineAccountsResponse>
""")
.build();

ResponseEntity<OpalS2SResponseWrapper> responseEntity = new ResponseEntity<>(response, HttpStatus.OK);

// Act
ResponseEntity<OpalS2SResponseWrapper> actualResponse = createFineAccountsController
.createFineAccounts(request);

// Assert
assertEquals(HttpStatus.OK, actualResponse.getStatusCode());
assertEquals(response, actualResponse.getBody());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ void testSearchDebtorProfile_Success() {
<ErrorMessage>Sample error message</ErrorMessage>
</DebtorProfileResponse>
""")
.errorDetail("")
.build();

ResponseEntity<OpalS2SResponseWrapper> responseEntity = new ResponseEntity<>(response, HttpStatus.OK);
Expand Down

0 comments on commit 2ef49ca

Please sign in to comment.