Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cas2v2/cba87 add application origin to the cas2v2 endpoint #2798

Open
wants to merge 13 commits into
base: cas2v2/dev
Choose a base branch
from

Conversation

tobybatchmoj
Copy link

No description provided.

@@ -35,6 +35,7 @@ CREATE TABLE cas_2_v2_applications
hdc_eligibility_date date,
conditional_release_date date,
telephone_number TEXT,
application_origin TEXT,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we generally shouldn't modify existing migrations. This change should be made in a new migration

@@ -35,6 +35,7 @@ CREATE TABLE cas_2_v2_applications
hdc_eligibility_date date,
conditional_release_date date,
telephone_number TEXT,
application_origin TEXT,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this should be not null?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -45,6 +46,7 @@ CREATE TABLE cas_2_v2_assessments
created_at TIMESTAMPTZ,
nacro_referral_id TEXT,
assessor_name TEXT,
applicationOrigin TEXT,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given this can be derived from the linked application, is this de-normalisation required

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've removed it.

@@ -45,6 +46,7 @@ CREATE TABLE cas_2_v2_assessments
created_at TIMESTAMPTZ,
nacro_referral_id TEXT,
assessor_name TEXT,
applicationOrigin TEXT,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

convention is to underscores in database column names

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now removed - see above comment.

@@ -16,4 +16,5 @@ data class DomainEvent<T>(
val data: T,
val metadata: Map<MetaDataName, String?> = emptyMap(),
val schemaVersion: Int? = null,
val applicationOrigin: String? = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this absolutely required given it can be derived from the linked application? If possible we should minimise CAS specific properties on shared types

}

// hdc application
val hdcApplicationEntity = cas2v2ApplicationEntityFactory.produceAndPersist {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think the three comments above are required

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

objectMapper.readValue(rawResponseBody, object : TypeReference<List<Cas2v2ApplicationSummary>>() {})

// check application origin is persisted and returned correctly
Assertions.assertThat(responseBody).anyMatch {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think the comment is required

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -402,6 +403,80 @@ class Cas2v2ApplicationTest : Cas2v2IntegrationTestBase() {
}
}

@Test
fun `Get all applications returns 200 with correct body including applicationOrigin`() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test is only checking application origin, maybe worth renaming to reflect that (e.g. remove 'correct body including')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -100,6 +100,7 @@ class Cas2v2ApplicationsTransformerTest {
"telephoneNumber",
"assessment",
"timelineEvents",
"applicationOrigin",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know you're just following what's already here but this isn't really testing the transform (it should really look at the value passed in is correctly returned). Same comment applies to other transformer test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. We have added an extra assert that verifies the applicationOrigin is transformed.

@@ -2193,6 +2200,8 @@ components:
offenceId:
type: string
example: "M1502750438"
applicationOrigin:
$ref: "#/components/schemas/ApplicationOrigin"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this should be mandatory for CAS2, but because this is a shared type that will break CAS1 and CAS3. I think this is good opportunity to introduce a CAS2 specific NewApplication type (e.g. Cas2NewApplication) and put it in the cas2 schemas yml, including this as a mandatory field. You may find that you can remove the other fields if they aren't required for CAS2. This type should then be used on your new cas2v2 endpoint. If you do this i don't think the PR should be updating _shared.yml at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants