Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .specify/feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"feature_directory": "specs/001-informant-register-local-schema"
}
5 changes: 5 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,9 @@ This repo uses Spec Kit. For non-trivial work use:
<!-- SPECKIT START -->
For additional context about technologies to be used, project structure,
shell commands, and other important information, read the current plan

**Active feature**: CIMD-3915 — Include Verdict in SJP Results
**Branch**: `CIMD-3915-informant-register-local-schema`
**Implementation plan**: [specs/001-informant-register-local-schema/plan.md](specs/001-informant-register-local-schema/plan.md)
**Quickstart**: [specs/001-informant-register-local-schema/quickstart.md](specs/001-informant-register-local-schema/quickstart.md)
<!-- SPECKIT END -->
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>uk.gov.moj.cpp.results</groupId>
<artifactId>results-parent</artifactId>
<version>17.104.111-SNAPSHOT</version>
<version>17.103.109-CIMD3915-SNAPSHOT</version>

<packaging>pom</packaging>
<name>Results Service - Parent Module</name>
Expand Down Expand Up @@ -41,7 +41,7 @@
<referencedata.version>17.103.133</referencedata.version>
<notification.notify.version>17.104.44</notification.notify.version>
<systemdocgenerator.version>17.104.111</systemdocgenerator.version>
<progression.version>17.0.262</progression.version>
<progression.version>17.0.266</progression.version>
<material.version>17.0.79</material.version>
<usersgroups.version>17.104.47</usersgroups.version>
<stream-transformation-tool-api.version>7.0.0</stream-transformation-tool-api.version>
Expand Down
2 changes: 1 addition & 1 deletion results-command/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>uk.gov.moj.cpp.results</groupId>
<artifactId>results-parent</artifactId>
<version>17.104.111-SNAPSHOT</version>
<version>17.103.109-CIMD3915-SNAPSHOT</version>
</parent>
<artifactId>results-command</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion results-command/results-command-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>uk.gov.moj.cpp.results</groupId>
<artifactId>results-command</artifactId>
<version>17.104.111-SNAPSHOT</version>
<version>17.103.109-CIMD3915-SNAPSHOT</version>
</parent>
<artifactId>results-command-api</artifactId>
<packaging>war</packaging>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://moj.gov.uk/cpp/results/command/add-informant-register-request.json",
"$ref": "http://justice.gov.uk/core/courts/informantRegisterDocument/informantRegisterDocumentRequest.json"
"$ref": "http://justice.gov.uk/results/courts/informantRegisterDocument/informantRegisterDocumentRequest.json"
}
2 changes: 1 addition & 1 deletion results-command/results-command-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>uk.gov.moj.cpp.results</groupId>
<artifactId>results-command</artifactId>
<version>17.104.111-SNAPSHOT</version>
<version>17.103.109-CIMD3915-SNAPSHOT</version>
</parent>
<artifactId>results-command-handler</artifactId>
<packaging>war</packaging>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
import static uk.gov.moj.cpp.domains.constant.RegisterStatus.RECORDED;
import static uk.gov.moj.cpp.results.command.util.DefendantMapper.getDefendants;

import uk.gov.justice.core.courts.InformantRegisterRecorded;
import uk.gov.justice.core.courts.ProsecutionCase;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterDefendant;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterDocumentRequest;
import uk.gov.justice.results.courts.InformantRegisterGeneratedV2;
import uk.gov.justice.results.courts.InformantRegisterRecordedV2;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterDefendant;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterDocumentRequest;
import uk.gov.justice.results.courts.GenerateInformantRegister;
import uk.gov.justice.results.courts.InformantRegisterGenerated;
import uk.gov.justice.results.courts.NotifyInformantRegister;
import uk.gov.justice.services.common.converter.JsonObjectToObjectConverter;
import uk.gov.justice.services.common.converter.StringToJsonObjectConverter;
Expand Down Expand Up @@ -95,7 +95,10 @@ public void handleAddInformantRegisterToEventStream(final Envelope<InformantRegi
final UUID informantRegisterId = getInformantRegisterStreamId(prosecutionAuthorityId.toString(), informantRegisterDocumentRequest.getRegisterDate().toLocalDate().toString());

final EventStream eventStream = eventSource.getStreamById(informantRegisterId);
final Stream<Object> events = Stream.of(new InformantRegisterRecorded(informantRegisterDocumentRequest, prosecutionAuthorityId));
final Stream<Object> events = Stream.of(InformantRegisterRecordedV2.informantRegisterRecordedV2()
.withProsecutionAuthorityId(prosecutionAuthorityId)
.withInformantRegister(informantRegisterDocumentRequest)
.build());

appendEventsToStream(envelope, eventStream, events);
}
Expand Down Expand Up @@ -163,7 +166,7 @@ private void processRequests(final UUID informantRegisterId, final List<JsonObje
.map(informantRegister -> jsonObjectToObjectConverter.convert(informantRegister, InformantRegisterDocumentRequest.class))
.toList();

final Stream<Object> events = Stream.of(InformantRegisterGenerated.informantRegisterGenerated()
final Stream<Object> events = Stream.of(InformantRegisterGeneratedV2.informantRegisterGeneratedV2()
.withInformantRegisterDocumentRequests(informantRegisterDocumentRequests)
.withSystemGenerated(systemGenerated)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import uk.gov.justice.core.courts.Defendant;
import uk.gov.justice.core.courts.PersonDefendant;
import uk.gov.justice.core.courts.ProsecutionCase;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterDefendant;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterDefendant;

import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import uk.gov.justice.core.courts.Defendant;
import uk.gov.justice.core.courts.ProsecutionCase;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterCaseOrApplication;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterDefendant;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterOffence;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterResult;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterCaseOrApplication;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterDefendant;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterOffence;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterResult;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://justice.gov.uk/core/courts/informantRegisterDocument/informant-register-document-request.json",
"$ref": "http://justice.gov.uk/core/courts/informantRegisterDocument/informantRegisterDocumentRequest.json"
"id": "http://justice.gov.uk/results/courts/informantRegisterDocument/command-add-informant-register-document-request.json",
"$ref": "http://justice.gov.uk/results/courts/informantRegisterDocument/informantRegisterDocumentRequest.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterDocumentRequest.informantRegisterDocumentRequest;
import static uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterRecipient.informantRegisterRecipient;
import static uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterDocumentRequest.informantRegisterDocumentRequest;
import static uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterRecipient.informantRegisterRecipient;
import static uk.gov.justice.services.core.annotation.Component.COMMAND_HANDLER;
import static uk.gov.justice.services.messaging.Envelope.envelopeFrom;
import static uk.gov.justice.services.messaging.Envelope.metadataFrom;
Expand All @@ -31,16 +31,18 @@
import static uk.gov.justice.services.test.utils.core.reflection.ReflectionUtil.setField;
import static uk.gov.moj.cpp.domains.InformantRegisterHelper.getInformantRegisterStreamId;

import uk.gov.justice.core.courts.InformantRegisterRecorded;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterCaseOrApplication;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterDefendant;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterDocumentRequest;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterHearing;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterHearingVenue;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterOffence;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterRecipient;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterResult;
import uk.gov.justice.core.courts.informantRegisterDocument.InformantRegisterResultData;
import uk.gov.justice.results.courts.InformantRegisterRecordedV2;
import uk.gov.justice.results.courts.InformantRegisterGeneratedV2;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterCaseOrApplication;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterDefendant;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterDocumentRequest;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterHearing;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterHearingVenue;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterOffence;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterRecipient;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterResult;
import uk.gov.justice.results.courts.informantRegisterDocument.InformantRegisterResultData;
import uk.gov.justice.results.courts.informantRegisterDocument.Verdict;
import uk.gov.justice.results.courts.GenerateInformantRegister;
import uk.gov.justice.results.courts.InformantRegisterGenerated;
import uk.gov.justice.results.courts.InformantRegisterNotificationIgnored;
Expand Down Expand Up @@ -138,7 +140,7 @@ public class InformantRegisterHandlerTest {
private final StringToJsonObjectConverter stringToJsonObjectConverter = new StringToJsonObjectConverter();

@Spy
private Enveloper enveloper = EnveloperFactory.createEnveloperWithEvents(InformantRegisterRecorded.class, InformantRegisterGenerated.class, InformantRegisterNotified.class, InformantRegisterNotifiedV2.class, InformantRegisterNotificationIgnored.class);
private Enveloper enveloper = EnveloperFactory.createEnveloperWithEvents(InformantRegisterGenerated.class, InformantRegisterNotified.class, InformantRegisterNotifiedV2.class, InformantRegisterNotificationIgnored.class, InformantRegisterRecordedV2.class, InformantRegisterGeneratedV2.class);

@BeforeEach
public void setup() {
Expand Down Expand Up @@ -167,7 +169,7 @@ public void shouldProcessCommand() throws Exception {

assertThat(envelopeStream, streamContaining(
jsonEnvelope(
metadata().withName("results.event.informant-register-recorded"),
metadata().withName("results.event.informant-register-recorded-v2"),
JsonEnvelopePayloadMatcher.payload().isJson(allOf(
withJsonPath("$.prosecutionAuthorityId", is(PROSECUTION_AUTHORITY_ID.toString())),
withJsonPath("$.informantRegister.prosecutionAuthorityId", is(PROSECUTION_AUTHORITY_ID.toString())),
Expand All @@ -189,7 +191,7 @@ public void shouldProcessCommandForGroupCases() throws Exception {

MatcherAssert.assertThat(envelopeStream, streamContaining(
jsonEnvelope(
metadata().withName("results.event.informant-register-recorded"),
metadata().withName("results.event.informant-register-recorded-v2"),
JsonEnvelopePayloadMatcher.payload().isJson(allOf(
withJsonPath("$.prosecutionAuthorityId", is(PROSECUTION_AUTHORITY_ID.toString())),
withJsonPath("$.informantRegister", notNullValue()),
Expand Down Expand Up @@ -250,7 +252,7 @@ public void shouldProcessCommandForGroupCasesWithoutDefAndCaseResults() throws E

MatcherAssert.assertThat(envelopeStream, streamContaining(
jsonEnvelope(
metadata().withName("results.event.informant-register-recorded"),
metadata().withName("results.event.informant-register-recorded-v2"),
JsonEnvelopePayloadMatcher.payload().isJson(allOf(
withJsonPath("$.prosecutionAuthorityId", is(PROSECUTION_AUTHORITY_ID.toString())),
withJsonPath("$.informantRegister", notNullValue()),
Expand Down Expand Up @@ -282,6 +284,25 @@ public void shouldProcessCommandForGroupCasesWithoutDefAndCaseResults() throws E
);
}

@Test
public void handleAddInformantRegisterToEventStream_withVerdictObject_shouldEmitV2RecordedEvent() throws Exception {
final UUID informantRegisterId = getInformantRegisterStreamId(PROSECUTION_AUTHORITY_ID.toString(), REGISTER_DATE.toLocalDate().toString());
when(eventSource.getStreamById(informantRegisterId)).thenReturn(eventStream);

informantRegisterHandler.handleAddInformantRegisterToEventStream(buildEnvelope());

final Stream<JsonEnvelope> envelopeStream = verifyAppendAndGetArgumentFrom(eventStream);
assertThat(envelopeStream, streamContaining(
jsonEnvelope(
metadata().withName("results.event.informant-register-recorded-v2"),
JsonEnvelopePayloadMatcher.payload().isJson(allOf(
withJsonPath("$.prosecutionAuthorityId", is(PROSECUTION_AUTHORITY_ID.toString())),
withJsonPath("$.informantRegister.prosecutionAuthorityId", is(PROSECUTION_AUTHORITY_ID.toString()))
))
)
));
}

@Test
public void generateInformantRegister() throws EventStreamException {
final Envelope<GenerateInformantRegister> generateInformantRegisterEnvelope = prepareEnvelope();
Expand Down Expand Up @@ -412,7 +433,7 @@ private void verifyInformantRegisterDocumentRequestHandlerResults() throws Event
assertThat(envelopeStream, streamContaining(
jsonEnvelope(
metadata()
.withName("results.event.informant-register-generated"),
.withName("results.event.informant-register-generated-v2"),
JsonEnvelopePayloadMatcher.payload().isJson(anyOf(
withJsonPath("$.informantRegisterDocumentRequests.length()", is(greaterThan(0)))
)
Expand Down Expand Up @@ -506,7 +527,7 @@ private final List<InformantRegisterCaseOrApplication> getCaseOrApplications(fin
.withOrderIndex(1)
.withOffenceTitle("offenceTitle_Main_" + i)
.withOffenceCode("offenceCode_Main_" + i)
.withVerdictCode("verdictCode_Main_" + i)
.withVerdict(Verdict.verdict().withVerdictCode("verdictCode_Main_" + i).build())
.withOriginatingCaseUrn("originatingCaseUrn_Main_" + i)
.withPleaValue("pleaValue_Main_" + i)
.withOffenceResults(getResults(RESULT_TYPE_OFFENCE, i, 1))
Expand Down
2 changes: 1 addition & 1 deletion results-domain/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>uk.gov.moj.cpp.results</groupId>
<artifactId>results-parent</artifactId>
<version>17.104.111-SNAPSHOT</version>
<version>17.103.109-CIMD3915-SNAPSHOT</version>
</parent>
<artifactId>results-domain</artifactId>
<packaging>pom</packaging>
Expand Down
2 changes: 1 addition & 1 deletion results-domain/results-domain-aggregate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>uk.gov.moj.cpp.results</groupId>
<artifactId>results-domain</artifactId>
<version>17.104.111-SNAPSHOT</version>
<version>17.103.109-CIMD3915-SNAPSHOT</version>
</parent>

<artifactId>results-domain-aggregate</artifactId>
Expand Down
Loading
Loading