use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class DocumentsDeletingListenerTest method testCancel.
@Test
public void testCancel() throws Exception {
Request request = mock(Request.class);
Job job = mock(Job.class);
JobStatus status = mock(JobStatus.class);
when(job.getRequest()).thenReturn(request);
when(request.isInteractive()).thenReturn(true);
when(job.getStatus()).thenReturn(status);
Map<EntityReference, EntitySelection> concernedEntities = new HashMap<>();
DocumentReference doc1 = new DocumentReference("a", "b", "c1");
concernedEntities.put(doc1, new EntitySelection(doc1));
XarInstalledExtension ext1 = mock(XarInstalledExtension.class);
when(ext1.getId()).thenReturn(new ExtensionId("ext1"));
when(repository.getXarInstalledExtensions(doc1)).thenReturn(Arrays.asList(ext1));
InterruptedException e = new InterruptedException();
doThrow(e).when(status).ask(any(), anyLong(), any());
// Test
DocumentsDeletingEvent event = mock(DocumentsDeletingEvent.class);
mocker.getComponentUnderTest().onEvent(event, job, concernedEntities);
// Check
verify(status, times(1)).ask(any(), eq(5L), eq(TimeUnit.MINUTES));
verify(event).cancel(eq("Question has been interrupted."));
verify(mocker.getMockedLogger()).warn("Confirm question has been interrupted.");
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class DefaultReferenceEntityReferenceResolverTest method resolveObjectPropertyReferenceWhenMissingParents.
/**
* Tests that a relative object property is resolved correctly and completed with the default object parent.
*/
@Test
public void resolveObjectPropertyReferenceWhenMissingParents() {
EntityReference reference = resolver.resolve(new EntityReference("property", EntityType.OBJECT_PROPERTY), EntityType.OBJECT_PROPERTY);
assertEquals(EntityType.OBJECT_PROPERTY, reference.getType());
assertEquals("property", reference.getName());
assertEquals(EntityType.OBJECT, reference.getParent().getType());
assertEquals(DEFAULT_OBJECT, reference.getParent().getName());
assertEquals(EntityType.DOCUMENT, reference.getParent().getParent().getType());
assertEquals(DEFAULT_PAGE, reference.getParent().getParent().getName());
assertEquals(EntityType.SPACE, reference.getParent().getParent().getParent().getType());
assertEquals(DEFAULT_SPACE, reference.getParent().getParent().getParent().getName());
assertEquals(EntityType.WIKI, reference.getParent().getParent().getParent().getParent().getType());
assertEquals(DEFAULT_WIKI, reference.getParent().getParent().getParent().getParent().getName());
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class DefaultReferenceEntityReferenceResolverTest method resolveSpaceReferenceWhenTypeIsDocument.
@Test
public void resolveSpaceReferenceWhenTypeIsDocument() {
EntityReference reference = this.resolver.resolve(new EntityReference("page", EntityType.DOCUMENT), EntityType.SPACE);
assertEquals(EntityType.SPACE, reference.getType());
assertEquals(DEFAULT_SPACE, reference.getName());
assertEquals(EntityType.WIKI, reference.getParent().getType());
assertEquals(DEFAULT_WIKI, reference.getParent().getName());
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class DefaultReferenceEntityReferenceResolverTest method resolveDocumentReferenceWhenMissingParents.
@Test
public void resolveDocumentReferenceWhenMissingParents() {
EntityReference partialReference = new EntityReference("page", EntityType.DOCUMENT);
EntityReference reference = this.resolver.resolve(partialReference, EntityType.DOCUMENT);
assertNotSame(partialReference, reference);
assertEquals(DEFAULT_SPACE, reference.getParent().getName());
assertEquals(EntityType.SPACE, reference.getParent().getType());
assertEquals(DEFAULT_WIKI, reference.getParent().getParent().getName());
assertEquals(EntityType.WIKI, reference.getParent().getParent().getType());
}
use of org.xwiki.model.reference.EntityReference in project xwiki-platform by xwiki.
the class DefaultReferenceEntityReferenceResolverTest method resolveAttachmentReferenceWhenMissingParents.
@Test
public void resolveAttachmentReferenceWhenMissingParents() {
EntityReference reference = this.resolver.resolve(new EntityReference("filename", EntityType.ATTACHMENT), EntityType.ATTACHMENT);
assertEquals(DEFAULT_PAGE, reference.getParent().getName());
assertEquals(EntityType.DOCUMENT, reference.getParent().getType());
assertEquals(DEFAULT_SPACE, reference.getParent().getParent().getName());
assertEquals(EntityType.SPACE, reference.getParent().getParent().getType());
assertEquals(DEFAULT_WIKI, reference.getParent().getParent().getParent().getName());
assertEquals(EntityType.WIKI, reference.getParent().getParent().getParent().getType());
}
Aggregations