Skip to content

Commit

Permalink
Add test from fcrepo#1080
Browse files Browse the repository at this point in the history
  • Loading branch information
whikloj committed Mar 25, 2020
1 parent a415565 commit 96b1b4b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
import static org.fcrepo.kernel.api.RdfLexicon.HAS_ORIGINAL_NAME;
import static org.fcrepo.kernel.api.RdfLexicon.INBOUND_REFERENCES;
import static org.fcrepo.kernel.api.RdfLexicon.INDIRECT_CONTAINER;
import static org.fcrepo.kernel.api.RdfLexicon.IS_MEMBER_OF_RELATION;
import static org.fcrepo.kernel.api.RdfLexicon.LAST_MODIFIED_BY;
import static org.fcrepo.kernel.api.RdfLexicon.LAST_MODIFIED_DATE;
import static org.fcrepo.kernel.api.RdfLexicon.LDP_MEMBER;
Expand Down Expand Up @@ -3499,6 +3500,75 @@ public void testIndirectContainerInteraction() throws IOException {
}
}

@Test
@Ignore
public void testIndirectContainerInteractionMemberOf() throws IOException {
// Create resource (object)
final String resourceId = getRandomUniqueId();
final String resource;
try (final CloseableHttpResponse createResponse = createObject(resourceId)) {
resource = getLocation(createResponse);
}
// Create container (c0)
final String containerId = getRandomUniqueId();
final String container;
try (final CloseableHttpResponse createResponse = createObject(containerId)) {
container = getLocation(createResponse);
}
// Create indirect container (c0/members)
final String indirectContainerId = containerId + "/t";
final HttpPut putIndirect = putObjMethod(indirectContainerId);
putIndirect.setHeader(LINK, INDIRECT_CONTAINER_LINK_HEADER);
final String indirectContainer;
try (final CloseableHttpResponse createResponse = execute(putIndirect)) {
indirectContainer = getLocation(createResponse);
}

// Add LDP properties to indirect container
final HttpPatch patch = patchObjMethod(indirectContainerId);
patch.addHeader("Content-Type", "application/sparql-update");
final String sparql = "INSERT DATA { "
+ "<> <" + MEMBERSHIP_RESOURCE + "> <" + container + "> .\n"
+ "<> <" + IS_MEMBER_OF_RELATION + "> <info:some/relation> .\n"
+ "<> <" + LDP_NAMESPACE + "insertedContentRelation> <info:proxy/for> .\n"
+ " }";
patch.setEntity(new StringEntity(sparql));
assertEquals("Expected patch to succeed", NO_CONTENT.getStatusCode(), getStatus(patch));

// Add indirect resource to indirect container
final HttpPost postIndirectResource = postObjMethod(indirectContainerId);
final String irRdf =
"<> <info:proxy/in> <" + container + "> ;\n" +
" <info:proxy/for> <" + resource + "> .";
postIndirectResource.setEntity(new StringEntity(irRdf));
postIndirectResource.setHeader("Content-Type", "text/turtle");

final String indirectResource;
try (final CloseableHttpResponse postResponse = execute(postIndirectResource)) {
indirectResource = getLocation(postResponse);
assertEquals("Expected post to succeed", CREATED.getStatusCode(), getStatus(postResponse));
}
// Ensure resource has been updated with relationship... indirectly
try (final CloseableHttpResponse getResponse = execute(new HttpGet(resource));
final CloseableDataset dataset = getDataset(getResponse)) {
final DatasetGraph graph = dataset.asDatasetGraph();
assertTrue("Expected to have triple on resource: " + createURI("info:some/relation") + " <"
+ createURI(container) + ">, graph: " + graph.toString(),
graph.contains(ANY, createURI(resource), createURI("info:some/relation"), createURI(container)));
}
// Remove indirect resource
assertEquals("Expected delete to succeed",
NO_CONTENT.getStatusCode(), getStatus(new HttpDelete(indirectResource)));

// Ensure resource has been updated with relationship... indirectly
try (final CloseableHttpResponse getResponse1 = execute(new HttpGet(resource));
final CloseableDataset dataset = getDataset(getResponse1)) {
final DatasetGraph graph1 = dataset.asDatasetGraph();
assertFalse("Expected NOT to have resource: " + graph1, graph1.contains(ANY,
createURI(resource), createURI("info:some/relation"), createURI(container)));
}
}

@Test
@Ignore
public void testWithHashUris() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ public final class RdfLexicon {
createProperty(LDP_NAMESPACE + "hasMemberRelation");
public static final Property INSERTED_CONTENT_RELATION =
createProperty(LDP_NAMESPACE + "insertedContentRelation");
public static final Property IS_MEMBER_OF_RELATION =
createProperty(LDP_NAMESPACE + "isMemberOfRelation");
public static final Property CONTAINS =
createProperty(LDP_NAMESPACE + "contains");
public static final Property LDP_MEMBER =
Expand Down

0 comments on commit 96b1b4b

Please sign in to comment.