Skip to content

Commit

Permalink
ensure rendered view saved in event history
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex McAusland committed Nov 7, 2024
1 parent 0489e5a commit 99c146c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ public void getEventHistory() throws Exception {
assertThat(response.getStatusLine().getStatusCode(), equalTo(200));
var auditEvents = (List) result.get("auditEvents");
assertThat(auditEvents.size(), equalTo(3));
var eventData = ((Map)auditEvents.get(0)).get("data");
var caseData = mapper.readValue(mapper.writeValueAsString(eventData), CaseData.class);
assertThat(caseData.getNotes().size(), equalTo(2));
}

private void addNote() throws Exception {
Expand Down Expand Up @@ -157,9 +160,6 @@ private void addNote() throws Exception {
var response = HttpClientBuilder.create().build().execute(e);
assertThat(response.getStatusLine().getStatusCode(), equalTo(201));
}
HttpGet buildGet(String user, String url) {
return buildRequest(user, url, HttpGet::new);
}

private String getAuthorisation(String user) {
return idam.getAccessToken(user, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ select jsonb_agg(to_jsonb(e) - 'case_reference' - 'event_id'
@SneakyThrows
private void saveAuditRecord(POCCaseDetails details, int version) {
var event = details.getEventDetails();
var data = details.getCaseDetails();
var caseView = getCase((Long) details.getCaseDetails().get("id"));
var currentView = mapper.readValue(caseView, Map.class);
db.update(
"""
insert into case_event (
Expand All @@ -168,21 +169,21 @@ insert into case_event (
security_classification)
values (?::jsonb,?::jsonb,?,?,?,?,?,?,?,?,?,?,?,?,?::securityclassification)
""",
mapper.writeValueAsString(data.get("case_data")),
mapper.writeValueAsString(data.get("data_classification")),
mapper.writeValueAsString(currentView.get("case_data")),
mapper.writeValueAsString(currentView.get("data_classification")),
event.getEventId(),
"user-id",
data.get("id"),
currentView.get("id"),
"NFD",
version,
data.get("state"),
currentView.get("state"),
"a-first-name",
"a-last-name",
event.getEventName(),
event.getStateName(),
event.getSummary(),
event.getDescription(),
data.get("security_classification")
currentView.get("security_classification")
);
}
@SneakyThrows
Expand Down

0 comments on commit 99c146c

Please sign in to comment.