Skip to content

Commit

Permalink
test to check creation of multiple relationships might fail
Browse files Browse the repository at this point in the history
  • Loading branch information
floriangantner committed Nov 14, 2023
1 parent 9940fcd commit 3bc0f1b
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ public class RelationshipsPositionIndexingIT extends AbstractEntityIntegrationTe
private Item publication2;
private Item publication3;
private Item publication4;

private Item publication5;
private Item project1;
private Item project2;

private RelationshipType selectedResearchOutputByAuthor;

private RelationshipType hiddenResearchOutputByAuthor;
private RelationshipType selectedResearchOutputByProject;

@Autowired
Expand Down Expand Up @@ -152,6 +156,12 @@ public void setUp() throws Exception {
.withIssueDate("2017-08-01")
.build();

publication5 = ItemBuilder.createItem(context, patentCollection)
.withTitle("Publication 5")
.withAuthor("Testzz, Foo")
.withIssueDate("2017-08-01")
.build();

project1 = ItemBuilder.createItem(context, projectCollection)
.withTitle("Project 1")
.build();
Expand All @@ -170,6 +180,16 @@ public void setUp() throws Exception {
0, null,
0, null).build();

selectedResearchOutputByAuthor = RelationshipTypeBuilder
.createRelationshipTypeBuilder(
context,
null,
personEntity,
"isResearchoutputsHiddenFor",
"notDisplayingResearchoutputs",
0, null,
0, null).build();

selectedResearchOutputByProject = RelationshipTypeBuilder
.createRelationshipTypeBuilder(
context,
Expand Down Expand Up @@ -443,6 +463,42 @@ public void relationPlacesIndexed() throws Exception {
configurationService.setProperty("relationship.places.onlyright", "");
}

@Test
public void relationPlacesIndexedShouldFail() throws Exception {
configurationService.setProperty("relationship.places.onlyright",
"null::Person::isResearchoutputsSelectedFor::hasSelectedResearchoutputs");
context.turnOffAuthorisationSystem();
final Relationship author1ToPublication1 =
RelationshipBuilder.createRelationshipBuilder(context, publication1,
author1, selectedResearchOutputByAuthor, -1, -1)
.build();
final Relationship author1ToPublication2 =
RelationshipBuilder.createRelationshipBuilder(context, publication2, author1,
selectedResearchOutputByAuthor,
-1, -1)
.build();

final Relationship author1ToPublication3 =
RelationshipBuilder.createRelationshipBuilder(context, publication3, author1,
hiddenResearchOutputByAuthor,
-1, -1)
.build();

final Relationship author1ToPublication4 =
RelationshipBuilder.createRelationshipBuilder(context, publication4, author1,
hiddenResearchOutputByAuthor,
-1, -1)
.build();
context.commit();
final Relationship author1ToPublication5 =
RelationshipBuilder.createRelationshipBuilder(context, publication5, author1,
selectedResearchOutputByAuthor,
-1, -1)
.build();
context.commit();
context.restoreAuthSystemState();
}

/**
* Test to verify scenario when an item is in a relation of the same name
* with different entities (i.e. a Publication selected from both a couple of researchers
Expand Down

0 comments on commit 3bc0f1b

Please sign in to comment.