-
Notifications
You must be signed in to change notification settings - Fork 0
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
Np 45284 person nvi data #329
Conversation
Test code for it's nested field verifiedBy
Feature getting large so i will continue in new branch. Current functionality is model classes and GET Person NVI data. The unit test and json shows what i have done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefere that all records was formatted the same wat, preferable with one field on each line, easier to read.
and you can also consider removing exxess json markup, but that is up to you
import no.unit.nva.cristin.model.CristinUnit; | ||
import no.unit.nva.model.Organization; | ||
|
||
public record CristinNviInstitutionUnit(@JsonProperty(INSTITUTION) CristinPersonNviInstitution institution, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Records serialize to json without any markups
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Meaning not having the need of JsonProperty...
public record CristinPersonNvi(@JsonProperty(VERIFIED_BY) CristinPersonSummary verifiedBy, | ||
@JsonProperty(VERIFIED_AT) CristinNviInstitutionUnit verifiedAt, | ||
@JsonProperty(VERIFIED_DATE) Instant verifiedDate) | ||
implements JsonSerializable { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intellij crashed when I tried JsonSerializable
on a record
I will try again...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works on my machine:
@Test
void testtest() {
var json = new CristinPersonNvi(
new CristinPersonSummary(randomString(), randomString(), null, "1234"),
new CristinNviInstitutionUnit(null, CristinUnit.fromCristinUnitIdentifier("183.5.5.5")),
null
);
System.out.println(json.toJsonString());
}
import no.unit.nva.cristin.person.model.nva.PersonSummary; | ||
import nva.commons.core.paths.UriWrapper; | ||
|
||
public record CristinPersonSummary(@JsonProperty(FIRST_NAME) String firstName, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really prefer this way of declaring a record, one line for each field, just like we declare a normal class.
It is much easier to read.
@@ -306,6 +311,22 @@ void shouldNotHaveEmploymentFieldInResponseWhenNotInUpstreamPayload() throws IOE | |||
assertThat(actual.getEmployments(), equalTo(null)); | |||
} | |||
|
|||
@Test | |||
void shouldReturnResponseContainingNviDataWhenPresentInUpstream() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always something new to learn from your tests....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did you learn?
No description provided.