Skip to content

Commit

Permalink
[DSC-1271] fixed broken ITs
Browse files Browse the repository at this point in the history
  • Loading branch information
eskander17 committed Oct 2, 2023
1 parent 3bf54e0 commit 29f9136
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ public void testWithAffiliationExtra() throws Exception {
.andExpect(status().isOk())
.andExpect(jsonPath("$._embedded.entries", containsInAnyOrder(
orcidEntry("Author From Orcid 1", REFERENCE, "0000-1111-2222-3333"),
orcidEntryWithInstitution("Author From Orcid 2", REFERENCE, "0000-2222-3333-4444", "Org1, Org2"),
orcidEntryWithInstitution("Author From Orcid 3", REFERENCE, "0000-5555-6666-7777", "Organization"))))
orcidEntryWithAffiliation("Author From Orcid 2", REFERENCE, "0000-2222-3333-4444", "Org1, Org2"),
orcidEntryWithAffiliation("Author From Orcid 3", REFERENCE, "0000-5555-6666-7777", "Organization"))))
.andExpect(jsonPath("$.page.size", Matchers.is(20)))
.andExpect(jsonPath("$.page.totalPages", Matchers.is(1)))
.andExpect(jsonPath("$.page.totalElements", Matchers.is(3)));
Expand Down Expand Up @@ -679,11 +679,18 @@ private Matcher<? super Object> orcidEntry(String title, String authorityPrefix,
title, "vocabularyEntry", ORCID_INFO, orcid);
}

private Matcher<? super Object> orcidEntryWithInstitution(String title, String authorityPrefix,
String orcid, String institutions) {
private Matcher<? super Object> orcidEntryWithAffiliation(String title, String authorityPrefix,
String orcid, String affiliation) {
String authority = authorityPrefix + "ORCID::" + orcid;
return ItemAuthorityMatcher.matchItemAuthorityWithTwoMetadataInOtherInformations(authority, title,
title, "vocabularyEntry", ORCID_INFO, orcid, ORCID_INSTITUTION, institutions);
return ItemAuthorityMatcher.matchItemAuthorityWithTwoMetadataInOtherInformations(
authority, title, title, "vocabularyEntry",
Map.of(
"data-" + ORCID_INFO, orcid,
ORCID_INFO, orcid,
"data-oairecerif_author_affiliation", affiliation,
"oairecerif_author_affiliation", affiliation
)
);
}

private String id(Item item) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public static Matcher<? super Object> matchItemAuthorityWithOtherInformations(St
hasJsonPath("$.display", is(display)),
hasJsonPath("$.value", is(value)),
hasJsonPath("$.type", is(type)),
hasJsonPath("$.otherInformation", aMapWithSize(1)),
hasJsonPath("$.otherInformation['" + otherInfMetadata + "']", is(metadataValue))
hasJsonPath("$.otherInformation", aMapWithSize(2)),
hasJsonPath("$.otherInformation['" + otherInfMetadata + "']", is(metadataValue)),
hasJsonPath("$.otherInformation['" + "data-" + otherInfMetadata + "']", is(metadataValue))
);
}

Expand Down Expand Up @@ -73,4 +74,18 @@ public static Matcher<? super Object> matchItemAuthorityWithTwoMetadataInOtherIn
)
);
}

public static Matcher<? super Object> matchItemAuthorityWithTwoMetadataInOtherInformations(String authority,
String display, String value, String type, Map<String, String> orcidAndAffiliation) {
return allOf(
hasJsonPath("$.authority", is(authority)),
hasJsonPath("$.display", is(display)),
hasJsonPath("$.value", is(value)),
hasJsonPath("$.type", is(type)),
hasJsonPath("$.otherInformation", aMapWithSize(4)),
allOf (
hasJsonPath("$.otherInformation", is(orcidAndAffiliation))
)
);
}
}

0 comments on commit 29f9136

Please sign in to comment.