/** * Check the activity of a resource and its parent. * @param resource the resource IRI * @param agent the agent IRI * @param activityType the activity type * @param resourceType the resource type * @param memberType the member type * @return a stream of tests */ default Stream<Executable> checkResourceParentLdpDC(final String resource, final String agent, final IRI activityType, final IRI resourceType, final IRI memberType) { return concat( checkResourceParentActivity(resource, getDirectContainerLocation(), agent, activityType, resourceType, LDP.DirectContainer), of(() -> await().atMost(15, SECONDS).until(() -> getMessages().stream() .anyMatch(checkEventGraph(getMemberLocation(), agent, AS.Update, memberType))))); }
/** * Check the activity of a resource and its parent. * @param resource the resource IRI * @param agent the agent IRI * @param activityType the activity type * @param resourceType the resource type * @param memberType the member type * @return a stream of tests */ default Stream<Executable> checkResourceParentLdpDC(final String resource, final String agent, final IRI activityType, final IRI resourceType, final IRI memberType) { return concat( checkResourceParentActivity(resource, getDirectContainerLocation(), agent, activityType, resourceType, LDP.DirectContainer), of(() -> await().atMost(15, SECONDS).until(() -> getMessages().stream() .anyMatch(checkEventGraph(getMemberLocation(), agent, AS.Update, memberType))))); }
/** * Test receiving a creation event message in a direct container. */ @Test @DisplayName("Test receiving a JMS creation message from a LDP-DC") default void testReceiveCreateMessageDC() { final String agent = "http://example.com/pat#i"; // POST an LDP-RS try (final Response res = target(getDirectContainerLocation()).request() .header(AUTHORIZATION, buildJwt(agent, getJwtSecret())).post(entity("", TEXT_TURTLE))) { assertEquals(SUCCESSFUL, res.getStatusInfo().getFamily(), "Check for a successful POST response"); assertAll("Check the LDP-DC parent", checkResourceParentLdpDC(res.getLocation().toString(), agent, AS.Create, LDP.RDFSource, LDP.Container)); } }
/** * Test receiving a creation event message in a direct container. */ @Test @DisplayName("Test receiving a JMS creation message from a LDP-DC") default void testReceiveCreateMessageDC() { final String agent = "http://example.com/pat#i"; // POST an LDP-RS try (final Response res = target(getDirectContainerLocation()).request() .header(AUTHORIZATION, buildJwt(agent, getJwtSecret())).post(entity("", TEXT_TURTLE))) { assertEquals(SUCCESSFUL, res.getStatusInfo().getFamily(), "Check for a successful POST response"); assertAll("Check the LDP-DC parent", checkResourceParentLdpDC(res.getLocation().toString(), agent, AS.Create, LDP.RDFSource, LDP.Container)); } }
/** * Test receiving a delete message. */ @Test @DisplayName("Test receiving a delete message in a LDP-DC") default void testReceiveDeleteMessageDC() { final String resource; final String agent = "http://example.com/george#i"; // POST an LDP-RS try (final Response res = target(getDirectContainerLocation()).request() .header(AUTHORIZATION, buildJwt(agent, getJwtSecret())).post(entity("", TEXT_TURTLE))) { assertEquals(SUCCESSFUL, res.getStatusInfo().getFamily(), "Check for a successful POST in an LDP-DC"); resource = res.getLocation().toString(); assertAll("Check the LDP-DC parent", checkResourceParentLdpDC(resource, agent, AS.Create, LDP.RDFSource, LDP.Container)); } final String agent2 = "https://pat.example.com/profile#me"; // DELETE the LDP-RS try (final Response res = target(resource).request().header(AUTHORIZATION, buildJwt(agent2, getJwtSecret())) .delete()) { assertEquals(SUCCESSFUL, res.getStatusInfo().getFamily(), "Check for a successful LDP-RS DELETE"); assertAll("Check the LDP-DC parent resource", checkResourceParentLdpDC(resource, agent2, AS.Delete, LDP.Resource, LDP.Container)); } }
/** * Test receiving a delete message. */ @Test @DisplayName("Test receiving a delete message in a LDP-DC") default void testReceiveDeleteMessageDC() { final String resource; final String agent = "http://example.com/george#i"; // POST an LDP-RS try (final Response res = target(getDirectContainerLocation()).request() .header(AUTHORIZATION, buildJwt(agent, getJwtSecret())).post(entity("", TEXT_TURTLE))) { assertEquals(SUCCESSFUL, res.getStatusInfo().getFamily(), "Check for a successful POST in an LDP-DC"); resource = res.getLocation().toString(); assertAll("Check the LDP-DC parent", checkResourceParentLdpDC(resource, agent, AS.Create, LDP.RDFSource, LDP.Container)); } final String agent2 = "https://pat.example.com/profile#me"; // DELETE the LDP-RS try (final Response res = target(resource).request().header(AUTHORIZATION, buildJwt(agent2, getJwtSecret())) .delete()) { assertEquals(SUCCESSFUL, res.getStatusInfo().getFamily(), "Check for a successful LDP-RS DELETE"); assertAll("Check the LDP-DC parent resource", checkResourceParentLdpDC(resource, agent2, AS.Delete, LDP.Resource, LDP.Container)); } }