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

Np 45284 person nvi data #329

Merged
merged 3 commits into from
Oct 18, 2023
Merged

Np 45284 person nvi data #329

merged 3 commits into from
Oct 18, 2023

Conversation

torarnet
Copy link
Contributor

No description provided.

@torarnet
Copy link
Contributor Author

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

Copy link
Contributor

@StigNorland StigNorland left a 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,
Copy link
Contributor

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

Copy link
Contributor Author

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 {
Copy link
Contributor

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...

Copy link
Contributor Author

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,
Copy link
Contributor

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 {
Copy link
Contributor

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....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What did you learn?

@torarnet torarnet merged commit f7b1409 into main Oct 18, 2023
6 checks passed
@torarnet torarnet deleted the np-45284-person-nvi-data branch October 18, 2023 12:18
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