Skip to content

Commit

Permalink
Merge pull request DSpace#9239 from toniprieto/vocabularies-search-by…
Browse files Browse the repository at this point in the history
…-metadata-and-collection

Correct response of get controlled vocabulary by metadata and collection when NO controlled vocabulary is available for the specified metadata and collection
  • Loading branch information
alanorth authored Jan 4, 2024
2 parents 4bf7d17 + a294f99 commit 068b1bd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ public VocabularyRest findByMetadataAndCollection(
}

String authorityName = cas.getChoiceAuthorityName(tokens[0], tokens[1], tokens[2], collection);
if (authorityName == null) {
return null;
}
ChoiceAuthority source = cas.getChoiceAuthorityByAuthorityName(authorityName);
return authorityUtils.convertAuthority(source, authorityName, utils.obtainProjection());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,20 @@ public void findByMetadataAndCollectionTest() throws Exception {
)));
}

@Test
public void findByMetadataAndCollectionWithMetadataWithoutVocabularyTest() throws Exception {
context.turnOffAuthorisationSystem();
Collection collection = CollectionBuilder.createCollection(context, parentCommunity)
.withName("Test collection")
.build();
context.restoreAuthSystemState();
String token = getAuthToken(admin.getEmail(), password);
getClient(token).perform(get("/api/submission/vocabularies/search/byMetadataAndCollection")
.param("metadata", "dc.title")
.param("collection", collection.getID().toString()))
.andExpect(status().isNoContent());
}

@Test
public void findByMetadataAndCollectionUnprocessableEntityTest() throws Exception {
context.turnOffAuthorisationSystem();
Expand Down

0 comments on commit 068b1bd

Please sign in to comment.