Search in sources :

Example 1 with PreferAccessControl

use of org.trellisldp.vocabulary.Trellis.PreferAccessControl in project trellis by trellis-ldp.

the class AbstractTrellisHttpResourceTest method testGetBinaryAcl.

@Test
void testGetBinaryAcl() {
    when(mockBinaryResource.stream(PreferAccessControl)).thenAnswer(inv -> Stream.of(rdf.createQuad(PreferAccessControl, binaryIdentifier, ACL.mode, ACL.Read)));
    try (final Response res = target(BINARY_PATH).queryParam(EXT, ACL_PARAM).request().get()) {
        assertEquals(SC_OK, res.getStatus(), ERR_RESPONSE_CODE);
        assertFalse(getLinks(res).stream().anyMatch(l -> l.getRel().equals(DESCRIBES)), "Unexpected rel=describes");
        assertFalse(getLinks(res).stream().anyMatch(l -> l.getRel().equals(DESCRIBEDBY)), "Unexpected rel=describedby");
        assertFalse(getLinks(res).stream().anyMatch(l -> l.getRel().equals("canonical")), "Unexpected rel=canonical");
        assertFalse(getLinks(res).stream().anyMatch(l -> l.getRel().equals("alternate")), "Unexpected rel=alternate");
    }
}
Also used : Response(javax.ws.rs.core.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) InvalidCardinality(org.trellisldp.vocabulary.Trellis.InvalidCardinality) TrellisRuntimeException(org.trellisldp.api.TrellisRuntimeException) XSD(org.trellisldp.vocabulary.XSD) Optional.of(java.util.Optional.of) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) ACCEPT_POST(org.trellisldp.common.HttpConstants.ACCEPT_POST) WILDCARD(javax.ws.rs.core.MediaType.WILDCARD) RDF.type(org.trellisldp.vocabulary.RDF.type) ACCEPT_DATETIME(org.trellisldp.common.HttpConstants.ACCEPT_DATETIME) Resource(org.trellisldp.api.Resource) Collections.singletonList(java.util.Collections.singletonList) MediaType(javax.ws.rs.core.MediaType) Instant.ofEpochSecond(java.time.Instant.ofEpochSecond) PreferAudit(org.trellisldp.vocabulary.Trellis.PreferAudit) TestInstance(org.junit.jupiter.api.TestInstance) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) PreferServerManaged(org.trellisldp.vocabulary.Trellis.PreferServerManaged) TypeReference(com.fasterxml.jackson.core.type.TypeReference) Collectors.toSet(java.util.stream.Collectors.toSet) DELETED_RESOURCE(org.trellisldp.api.Resource.SpecialResources.DELETED_RESOURCE) PREFER(org.trellisldp.common.HttpConstants.PREFER) RANGE(org.trellisldp.common.HttpConstants.RANGE) DC(org.trellisldp.vocabulary.DC) Collections.emptyList(java.util.Collections.emptyList) Predicate(java.util.function.Predicate) APPLICATION_LINK_FORMAT(org.trellisldp.common.HttpConstants.APPLICATION_LINK_FORMAT) Set(java.util.Set) ConfigProvider.getConfig(org.eclipse.microprofile.config.ConfigProvider.getConfig) Instant(java.time.Instant) ACCEPT_RANGES(org.trellisldp.common.HttpConstants.ACCEPT_RANGES) Test(org.junit.jupiter.api.Test) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) HttpHeaders(javax.ws.rs.core.HttpHeaders) Stream(java.util.stream.Stream) APPLICATION_LD_JSON(org.trellisldp.common.RdfMediaType.APPLICATION_LD_JSON) Response(javax.ws.rs.core.Response) StorageConflictException(org.trellisldp.api.StorageConflictException) UTC(java.time.ZoneOffset.UTC) TRELLIS_DATA_PREFIX(org.trellisldp.api.TrellisUtils.TRELLIS_DATA_PREFIX) Arrays.stream(java.util.Arrays.stream) Link(javax.ws.rs.core.Link) Optional.empty(java.util.Optional.empty) InvalidRange(org.trellisldp.vocabulary.Trellis.InvalidRange) APPLICATION_N_TRIPLES(org.trellisldp.common.RdfMediaType.APPLICATION_N_TRIPLES) ACL(org.trellisldp.vocabulary.ACL) Entity.entity(javax.ws.rs.client.Entity.entity) PreferAccessControl(org.trellisldp.vocabulary.Trellis.PreferAccessControl) HttpMethod(javax.ws.rs.HttpMethod) TreeSet(java.util.TreeSet) SLUG(org.trellisldp.common.HttpConstants.SLUG) TIMEMAP(org.trellisldp.common.HttpConstants.TIMEMAP) MEMENTO_DATETIME(org.trellisldp.common.HttpConstants.MEMENTO_DATETIME) APPLICATION_SPARQL_UPDATE(org.trellisldp.common.RdfMediaType.APPLICATION_SPARQL_UPDATE) MAX(java.time.Instant.MAX) CONFIG_HTTP_PUT_UNCONTAINED(org.trellisldp.common.HttpConstants.CONFIG_HTTP_PUT_UNCONTAINED) Date.from(java.util.Date.from) CompletableFuture.supplyAsync(java.util.concurrent.CompletableFuture.supplyAsync) ACCEPT_PATCH(org.trellisldp.common.HttpConstants.ACCEPT_PATCH) Assumptions.assumeTrue(org.junit.jupiter.api.Assumptions.assumeTrue) LDP(org.trellisldp.vocabulary.LDP) ValueSource(org.junit.jupiter.params.provider.ValueSource) APPLICATION_LD_JSON_TYPE(org.trellisldp.common.RdfMediaType.APPLICATION_LD_JSON_TYPE) TEXT_TURTLE_TYPE(org.trellisldp.common.RdfMediaType.TEXT_TURTLE_TYPE) UTF_8(java.nio.charset.StandardCharsets.UTF_8) HttpServletResponse(javax.servlet.http.HttpServletResponse) EXT(org.trellisldp.common.HttpConstants.EXT) Predicate.isEqual(java.util.function.Predicate.isEqual) IOException(java.io.IOException) TEXT_PLAIN_TYPE(javax.ws.rs.core.MediaType.TEXT_PLAIN_TYPE) Mockito(org.mockito.Mockito) Collectors.toList(java.util.stream.Collectors.toList) IRI(org.apache.commons.rdf.api.IRI) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Quad(org.apache.commons.rdf.api.Quad) Executable(org.junit.jupiter.api.function.Executable) Assertions(org.junit.jupiter.api.Assertions) RFC_1123_DATE_TIME(java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME) MISSING_RESOURCE(org.trellisldp.api.Resource.SpecialResources.MISSING_RESOURCE) PreferUserManaged(org.trellisldp.vocabulary.Trellis.PreferUserManaged) ZonedDateTime.parse(java.time.ZonedDateTime.parse) NotificationService(org.trellisldp.api.NotificationService) InputStream(java.io.InputStream) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Instant (java.time.Instant)1 MAX (java.time.Instant.MAX)1 Instant.ofEpochSecond (java.time.Instant.ofEpochSecond)1 UTC (java.time.ZoneOffset.UTC)1 ZonedDateTime.parse (java.time.ZonedDateTime.parse)1 RFC_1123_DATE_TIME (java.time.format.DateTimeFormatter.RFC_1123_DATE_TIME)1 Arrays.asList (java.util.Arrays.asList)1 Arrays.stream (java.util.Arrays.stream)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.singletonList (java.util.Collections.singletonList)1 Date.from (java.util.Date.from)1 List (java.util.List)1 Map (java.util.Map)1 Optional.empty (java.util.Optional.empty)1 Optional.of (java.util.Optional.of)1 Set (java.util.Set)1