当前位置: 首页>>代码示例>>Java>>正文


Java AS类代码示例

本文整理汇总了Java中org.trellisldp.vocabulary.AS的典型用法代码示例。如果您正苦于以下问题:Java AS类的具体用法?Java AS怎么用?Java AS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


AS类属于org.trellisldp.vocabulary包,在下文中一共展示了AS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: from

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
/**
 * Populate a ActivityStreamMessage from an Event.
 *
 * @param event The event
 * @return an ActivityStreamMessage
 */
public static ActivityStreamMessage from(final Event event) {

    final ActivityStreamMessage msg = new ActivityStreamMessage();

    msg.id = event.getIdentifier().getIRIString();
    msg.type = event.getTypes().stream().map(IRI::getIRIString)
        .map(type -> type.startsWith(AS.URI) ? type.substring(AS.URI.length()) : type)
        .collect(toList());

    msg.published = event.getCreated().toString();

    final List<String> actors = event.getAgents().stream().map(IRI::getIRIString).collect(toList());
    msg.actor = actors.isEmpty() ? null : actors;

    event.getInbox().map(IRI::getIRIString).ifPresent(inbox -> msg.inbox = inbox);
    event.getTarget().map(IRI::getIRIString).ifPresent(target ->
        msg.object = new EventResource(target,
                event.getTargetTypes().stream().map(IRI::getIRIString).collect(toList())));

    return msg;
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:28,代码来源:ActivityStreamMessage.java

示例2: setUp

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@BeforeEach
public void setUp() throws JMSException {
    initMocks(this);
    when(mockEvent.getTarget()).thenReturn(of(rdf.createIRI("trellis:repository/resource")));
    when(mockEvent.getAgents()).thenReturn(singleton(Trellis.AdministratorAgent));
    when(mockEvent.getCreated()).thenReturn(time);
    when(mockEvent.getIdentifier()).thenReturn(rdf.createIRI("urn:test"));
    when(mockEvent.getTypes()).thenReturn(singleton(AS.Update));
    when(mockEvent.getTargetTypes()).thenReturn(singleton(LDP.RDFSource));
    when(mockEvent.getInbox()).thenReturn(empty());

    when(mockConnection.createSession(anyBoolean(), eq(AUTO_ACKNOWLEDGE))).thenReturn(mockSession);
    when(mockSession.createQueue(eq(queueName))).thenReturn(mockQueue);
    when(mockSession.createTextMessage(anyString())).thenReturn(mockMessage);
    when(mockSession.createProducer(any(Queue.class))).thenReturn(mockProducer);

    doNothing().when(mockProducer).send(any(TextMessage.class));
}
 
开发者ID:trellis-ldp,项目名称:trellis-jms,代码行数:19,代码来源:JmsPublisherTest.java

示例3: from

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
/**
 * Populate a ActivityStreamMessage from an Event
 * @param event The event
 * @return an ActivityStreamMessage
 */
public static ActivityStreamMessage from(final Event event) {

    final ActivityStreamMessage msg = new ActivityStreamMessage();

    msg.id = event.getIdentifier().getIRIString();
    msg.type = event.getTypes().stream().map(IRI::getIRIString)
        .map(type -> type.startsWith(AS.URI) ? type.substring(AS.URI.length()) : type)
        .collect(toList());

    msg.published = event.getCreated().toString();

    final List<String> actors = event.getAgents().stream().map(IRI::getIRIString).collect(toList());
    msg.actor = actors.isEmpty() ? null : actors;

    event.getInbox().map(IRI::getIRIString).ifPresent(inbox -> msg.inbox = inbox);
    event.getTarget().map(IRI::getIRIString).ifPresent(target ->
        msg.object = new EventResource(target,
                event.getTargetTypes().stream().map(IRI::getIRIString).collect(toList())));

    return msg;
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-event-serialization,代码行数:27,代码来源:ActivityStreamMessage.java

示例4: testSerializationStructure

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testSerializationStructure() throws Exception {
    when(mockEvent.getTypes()).thenReturn(asList(Create, Activity));

    final Optional<String> json = svc.serialize(mockEvent);
    assertTrue(json.isPresent());

    final ObjectMapper mapper = new ObjectMapper();
    @SuppressWarnings("unchecked")
    final Map<String, Object> map = mapper.readValue(json.get(), Map.class);
    assertTrue(map.containsKey("@context"));
    assertTrue(map.containsKey("id"));
    assertTrue(map.containsKey("type"));
    assertTrue(map.containsKey("inbox"));
    assertTrue(map.containsKey("actor"));
    assertTrue(map.containsKey("object"));
    assertTrue(map.containsKey("published"));

    final List types = (List) map.get("type");
    assertTrue(types.contains("Create"));
    assertTrue(types.contains(Activity.getIRIString()));

    assertTrue(AS.URI.contains((String) map.get("@context")));

    final List actor = (List) map.get("actor");
    assertTrue(actor.contains("info:user/test"));

    assertTrue(map.get("id").equals("info:event/12345"));
    assertTrue(map.get("inbox").equals("info:ldn/inbox"));
    assertTrue(map.get("published").equals(time.toString()));
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:32,代码来源:EventSerializerTest.java

示例5: testSerializationStructureNoEmptyElements

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testSerializationStructureNoEmptyElements() throws Exception {
    when(mockEvent.getInbox()).thenReturn(empty());
    when(mockEvent.getAgents()).thenReturn(emptyList());
    when(mockEvent.getTargetTypes()).thenReturn(emptyList());

    final Optional<String> json = svc.serialize(mockEvent);
    assertTrue(json.isPresent());

    final ObjectMapper mapper = new ObjectMapper();
    @SuppressWarnings("unchecked")
    final Map<String, Object> map = mapper.readValue(json.get(), Map.class);
    assertTrue(map.containsKey("@context"));
    assertTrue(map.containsKey("id"));
    assertTrue(map.containsKey("type"));
    assertFalse(map.containsKey("inbox"));
    assertFalse(map.containsKey("actor"));
    assertTrue(map.containsKey("object"));
    assertTrue(map.containsKey("published"));

    final List types = (List) map.get("type");
    assertTrue(types.contains("Create"));

    @SuppressWarnings("unchecked")
    final Map<String, Object> obj = (Map<String, Object>) map.get("object");
    assertTrue(obj.containsKey("id"));
    assertFalse(obj.containsKey("type"));

    assertTrue(AS.URI.contains((String) map.get("@context")));

    assertTrue(map.get("id").equals("info:event/12345"));
    assertTrue(map.get("published").equals(time.toString()));
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:34,代码来源:EventSerializerTest.java

示例6: testAuditCreation

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testAuditCreation() {
    final Dataset dataset = rdf.createDataset();
    final AuditService svc = new DefaultAuditService();
    svc.creation(subject, mockSession).forEach(dataset::add);
    assertTrue(dataset.getGraph(Trellis.PreferAudit).filter(graph -> graph.size() == dataset.size()).isPresent());
    assertTrue(dataset.contains(null, null, type, PROV.Activity));
    assertTrue(dataset.contains(null, null, type, AS.Create));
    assertTrue(dataset.contains(null, subject, PROV.wasGeneratedBy, null));
    assertTrue(dataset.contains(null, null, PROV.wasAssociatedWith, Trellis.AnonymousAgent));
    assertTrue(dataset.contains(null, null, PROV.actedOnBehalfOf, Trellis.AdministratorAgent));
    assertTrue(dataset.contains(null, null, PROV.startedAtTime,
                rdf.createLiteral(created.toString(), XSD.dateTime)));
    assertEquals(6L, dataset.size());
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:16,代码来源:DefaultAuditServiceTest.java

示例7: testAuditDeletion

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testAuditDeletion() {
    final Dataset dataset = rdf.createDataset();
    final AuditService svc = new DefaultAuditService();
    svc.deletion(subject, mockSession).forEach(dataset::add);
    assertTrue(dataset.getGraph(Trellis.PreferAudit).filter(graph -> graph.size() == dataset.size()).isPresent());
    assertTrue(dataset.contains(null, null, type, PROV.Activity));
    assertTrue(dataset.contains(null, null, type, AS.Delete));
    assertTrue(dataset.contains(null, subject, PROV.wasGeneratedBy, null));
    assertTrue(dataset.contains(null, null, PROV.wasAssociatedWith, Trellis.AnonymousAgent));
    assertTrue(dataset.contains(null, null, PROV.actedOnBehalfOf, Trellis.AdministratorAgent));
    assertTrue(dataset.contains(null, null, PROV.startedAtTime,
                rdf.createLiteral(created.toString(), XSD.dateTime)));
    assertEquals(6L, dataset.size());
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:16,代码来源:DefaultAuditServiceTest.java

示例8: testAuditUpdate

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testAuditUpdate() {
    final Dataset dataset = rdf.createDataset();
    final AuditService svc = new DefaultAuditService();
    svc.update(subject, mockSession).forEach(dataset::add);
    assertTrue(dataset.getGraph(Trellis.PreferAudit).filter(graph -> graph.size() == dataset.size()).isPresent());
    assertTrue(dataset.contains(null, null, type, PROV.Activity));
    assertTrue(dataset.contains(null, null, type, AS.Update));
    assertTrue(dataset.contains(null, subject, PROV.wasGeneratedBy, null));
    assertTrue(dataset.contains(null, null, PROV.wasAssociatedWith, Trellis.AnonymousAgent));
    assertTrue(dataset.contains(null, null, PROV.actedOnBehalfOf, Trellis.AdministratorAgent));
    assertTrue(dataset.contains(null, null, PROV.startedAtTime,
                rdf.createLiteral(created.toString(), XSD.dateTime)));
    assertEquals(6L, dataset.size());
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:16,代码来源:DefaultAuditServiceTest.java

示例9: setUp

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@BeforeEach
public void setUp() {
    initMocks(this);
    final IRI iri = rdf.createIRI("trellis:repo");
    when(mockResource.getModified()).thenReturn(time);
    when(mockResource.getIdentifier()).thenReturn(iri);
    when(mockResource.getMementos()).thenReturn(emptyList());
    when(mockResource.getExtraLinkRelations()).thenAnswer(inv -> Stream.empty());

    when(mockResourceService.skolemize(any(BlankNode.class)))
        .thenReturn(rdf.createIRI(TRELLIS_BNODE_PREFIX + "foo"));
    when(mockResourceService.skolemize(eq(iri))).thenReturn(iri);
    when(mockResourceService.skolemize(eq(AS.Delete))).thenReturn(AS.Delete);
    when(mockResourceService.skolemize(eq(PROV.Activity))).thenReturn(PROV.Activity);
    when(mockResourceService.skolemize(eq(Trellis.AnonymousAgent))).thenReturn(Trellis.AnonymousAgent);
    when(mockResourceService.skolemize(eq(date))).thenReturn(date);
    when(mockResourceService.put(eq(iri), any(IRI.class), any(Dataset.class))).thenReturn(completedFuture(true));

    when(mockLdpRequest.getSession()).thenReturn(mockSession);
    when(mockLdpRequest.getBaseUrl()).thenReturn(baseUrl);
    when(mockLdpRequest.getPath()).thenReturn("/");
    when(mockLdpRequest.getRequest()).thenReturn(mockRequest);

    when(mockSession.getCreated()).thenReturn(time);
    when(mockSession.getAgent()).thenReturn(Trellis.AnonymousAgent);
    when(mockSession.getDelegatedBy()).thenReturn(empty());
    when(mockResourceService.toInternal(any(RDFTerm.class), any())).thenAnswer(inv -> {
        final RDFTerm term = (RDFTerm) inv.getArgument(0);
        final String base = (String) inv.getArgument(1);
        if (term instanceof IRI) {
            final String iriString = ((IRI) term).getIRIString();
            if (iriString.startsWith(base)) {
                return rdf.createIRI(TRELLIS_PREFIX + iriString.substring(base.length()));
            }
        }
        return term;
    });
}
 
开发者ID:trellis-ldp,项目名称:trellis,代码行数:39,代码来源:DeleteHandlerTest.java

示例10: testAuditCreation

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testAuditCreation() {
    final Dataset dataset = rdf.createDataset();
    final AuditService svc = new DefaultAuditService();
    svc.creation(subject, mockSession).forEach(dataset::add);
    assertTrue(dataset.getGraph(Trellis.PreferAudit).filter(graph -> graph.size() == dataset.size()).isPresent());
    assertTrue(dataset.contains(null, null, type, PROV.Activity));
    assertTrue(dataset.contains(null, null, type, AS.Create));
    assertTrue(dataset.contains(null, subject, PROV.wasGeneratedBy, null));
    assertTrue(dataset.contains(null, null, PROV.wasAssociatedWith, Trellis.AnonymousUser));
    assertTrue(dataset.contains(null, null, PROV.actedOnBehalfOf, Trellis.RepositoryAdministrator));
    assertTrue(dataset.contains(null, null, PROV.startedAtTime,
                rdf.createLiteral(created.toString(), XSD.dateTime)));
    assertEquals(6L, dataset.size());
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-audit,代码行数:16,代码来源:DefaultAuditServiceTest.java

示例11: testAuditDeletion

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testAuditDeletion() {
    final Dataset dataset = rdf.createDataset();
    final AuditService svc = new DefaultAuditService();
    svc.deletion(subject, mockSession).forEach(dataset::add);
    assertTrue(dataset.getGraph(Trellis.PreferAudit).filter(graph -> graph.size() == dataset.size()).isPresent());
    assertTrue(dataset.contains(null, null, type, PROV.Activity));
    assertTrue(dataset.contains(null, null, type, AS.Delete));
    assertTrue(dataset.contains(null, subject, PROV.wasGeneratedBy, null));
    assertTrue(dataset.contains(null, null, PROV.wasAssociatedWith, Trellis.AnonymousUser));
    assertTrue(dataset.contains(null, null, PROV.actedOnBehalfOf, Trellis.RepositoryAdministrator));
    assertTrue(dataset.contains(null, null, PROV.startedAtTime,
                rdf.createLiteral(created.toString(), XSD.dateTime)));
    assertEquals(6L, dataset.size());
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-audit,代码行数:16,代码来源:DefaultAuditServiceTest.java

示例12: testAuditUpdate

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testAuditUpdate() {
    final Dataset dataset = rdf.createDataset();
    final AuditService svc = new DefaultAuditService();
    svc.update(subject, mockSession).forEach(dataset::add);
    assertTrue(dataset.getGraph(Trellis.PreferAudit).filter(graph -> graph.size() == dataset.size()).isPresent());
    assertTrue(dataset.contains(null, null, type, PROV.Activity));
    assertTrue(dataset.contains(null, null, type, AS.Update));
    assertTrue(dataset.contains(null, subject, PROV.wasGeneratedBy, null));
    assertTrue(dataset.contains(null, null, PROV.wasAssociatedWith, Trellis.AnonymousUser));
    assertTrue(dataset.contains(null, null, PROV.actedOnBehalfOf, Trellis.RepositoryAdministrator));
    assertTrue(dataset.contains(null, null, PROV.startedAtTime,
                rdf.createLiteral(created.toString(), XSD.dateTime)));
    assertEquals(6L, dataset.size());
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-audit,代码行数:16,代码来源:DefaultAuditServiceTest.java

示例13: setUp

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@BeforeEach
public void setUp() throws IOException {
    initMocks(this);
    when(mockEvent.getTarget()).thenReturn(of(rdf.createIRI("trellis:repository/resource")));
    when(mockEvent.getAgents()).thenReturn(singleton(Trellis.AdministratorAgent));
    when(mockEvent.getCreated()).thenReturn(time);
    when(mockEvent.getIdentifier()).thenReturn(rdf.createIRI("urn:test"));
    when(mockEvent.getTypes()).thenReturn(singleton(AS.Update));
    when(mockEvent.getTargetTypes()).thenReturn(singleton(LDP.RDFSource));
    when(mockEvent.getInbox()).thenReturn(empty());
    doNothing().when(mockChannel).basicPublish(eq(exchangeName), eq(queueName), anyBoolean(), anyBoolean(),
            any(BasicProperties.class), any(byte[].class));
}
 
开发者ID:trellis-ldp,项目名称:trellis-amqp,代码行数:14,代码来源:AmqpPublisherTest.java

示例14: testNotification

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testNotification() {
    final IRI resource = rdf.createIRI(identifier);
    final Dataset dataset = rdf.createDataset();
    dataset.add(rdf.createQuad(Trellis.PreferUserManaged, resource, LDP.inbox, inbox));
    dataset.add(rdf.createQuad(Trellis.PreferAudit, rdf.createBlankNode(), PROV.wasAssociatedWith, agent));
    dataset.add(rdf.createQuad(Trellis.PreferServerManaged, resource, type, LDP.RDFSource));
    dataset.add(rdf.createQuad(Trellis.PreferUserManaged, resource, type, SKOS.Concept));
    dataset.add(rdf.createQuad(Trellis.PreferAudit, rdf.createBlankNode(), type, PROV.Activity));
    dataset.add(rdf.createQuad(Trellis.PreferAudit, rdf.createBlankNode(), type, AS.Create));

    final Instant time = now();

    final Notification event = new Notification(identifier, dataset);
    assertFalse(time.isAfter(event.getCreated()));
    assertTrue(event.getIdentifier().getIRIString().startsWith("urn:uuid:"));
    assertEquals(of(resource), event.getTarget());
    assertEquals(of(inbox), event.getInbox());
    assertEquals(1L, event.getAgents().size());
    assertTrue(event.getAgents().contains(agent));
    final Collection<IRI> targetTypes = event.getTargetTypes();
    assertEquals(2L, targetTypes.size());
    assertTrue(targetTypes.contains(LDP.RDFSource));
    assertTrue(targetTypes.contains(SKOS.Concept));
    final Collection<IRI> eventTypes = event.getTypes();
    assertEquals(2L, eventTypes.size());
    assertTrue(eventTypes.contains(AS.Create));
    assertTrue(eventTypes.contains(PROV.Activity));
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:30,代码来源:NotificationTest.java

示例15: testPutCreate

import org.trellisldp.vocabulary.AS; //导入依赖的package包/类
@Test
public void testPutCreate() throws InterruptedException, ExecutionException {
    final Dataset dataset = rdf.createDataset();
    dataset.add(rdf.createQuad(Trellis.PreferAudit, rdf.createBlankNode(), type, AS.Create));

    final ResourceService svc = new MyResourceService(curator.getConnectString(), null, null);
    assertTrue(svc.put(resource, LDP.RDFSource, dataset).get());
    assertFalse(svc.put(existing, LDP.NonRDFSource, dataset).get());
    assertFalse(svc.put(unwritable, LDP.Container, dataset).get());
    verify(mockEventService, times(0)).emit(any(Notification.class));
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:12,代码来源:AbstractResourceServiceTest.java


注:本文中的org.trellisldp.vocabulary.AS类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。