Search in sources :

Example 91 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class DocumentTreeNodeTest method configure.

@Before
public void configure() throws Exception {
    this.currentEntityReferenceResolver = this.mocker.getInstance(EntityReferenceResolver.TYPE_STRING, "current");
    this.defaultEntityReferenceSerializer = this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
    this.defaultEntityReferenceProvider = this.mocker.getInstance(EntityReferenceProvider.class);
    this.authorization = this.mocker.getInstance(ContextualAuthorizationManager.class);
    this.queryManager = this.mocker.getInstance(QueryManager.class);
    when(this.defaultEntityReferenceProvider.getDefaultReference(EntityType.DOCUMENT)).thenReturn(new EntityReference("WebHome", EntityType.DOCUMENT));
    when(this.currentEntityReferenceResolver.resolve("wiki:Path.To.Page.WebHome", EntityType.DOCUMENT)).thenReturn(documentReference);
    when(this.defaultEntityReferenceSerializer.serialize(documentReference)).thenReturn("wiki:Path.To.Page.WebHome");
    when(this.queryManager.getNamedQuery("nestedPagesOrderedByName")).thenReturn(this.nestedPagesOrderedByName);
    when(this.nestedPagesOrderedByName.addFilter(any(QueryFilter.class))).thenReturn(this.nestedPagesOrderedByName);
    this.contextComponentManagerProvider = this.mocker.registerMockComponent(new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context");
    when(this.contextComponentManagerProvider.get()).thenReturn(this.mocker);
    this.translationsTreeNode = this.mocker.registerMockComponent(TreeNode.class, "translations");
    this.attachmentsTreeNode = this.mocker.registerMockComponent(TreeNode.class, "attachments");
    this.classPropertiesTreeNode = this.mocker.registerMockComponent(TreeNode.class, "classProperties");
    this.objectsTreeNode = this.mocker.registerMockComponent(TreeNode.class, "objects");
}
Also used : ContextualAuthorizationManager(org.xwiki.security.authorization.ContextualAuthorizationManager) EntityReferenceProvider(org.xwiki.model.reference.EntityReferenceProvider) QueryFilter(org.xwiki.query.QueryFilter) TreeNode(org.xwiki.tree.TreeNode) QueryManager(org.xwiki.query.QueryManager) EntityReference(org.xwiki.model.reference.EntityReference) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) Before(org.junit.Before)

Example 92 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class ExportURLFactory method init.

/**
 * Init the url factory.
 *
 * @param exportedPages the pages that will be exported.
 * @param exportDir the directory where to copy exported objects (attachments).
 * @param context the XWiki context.
 * @deprecated starting with 8.4.5/9.0, use {@link #init(Collection, File, FilesystemExportContext, XWikiContext)}
 */
@Deprecated
public void init(Collection<String> exportedPages, File exportDir, XWikiContext context) {
    Provider<FilesystemExportContext> exportContextProvider = Utils.getComponent(new DefaultParameterizedType(null, Provider.class, FilesystemExportContext.class));
    DocumentReferenceResolver<String> resolver = Utils.getComponent(DocumentReferenceResolver.TYPE_STRING, "current");
    List<DocumentReference> references = new ArrayList<>();
    for (String exportedPage : exportedPages) {
        references.add(resolver.resolve(exportedPage));
    }
    init(references, exportDir, exportContextProvider.get(), context);
}
Also used : ArrayList(java.util.ArrayList) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) FilesystemExportContext(org.xwiki.url.filesystem.FilesystemExportContext) DocumentReference(org.xwiki.model.reference.DocumentReference) Provider(javax.inject.Provider)

Example 93 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class DBListClassPropertyValuesProviderTest method configure.

@Before
public void configure() throws Exception {
    super.configure();
    addProperty("category", this.dbListClass, true);
    addProperty("date", new DateClass(), false);
    when(this.xcontext.getWiki().getDocument(new ClassPropertyReference("status", this.classReference), this.xcontext)).thenReturn(this.classDocument);
    this.entityReferenceSerializer = this.mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
    this.authorExecutor = this.mocker.getInstance(AuthorExecutor.class);
    DefaultParameterizedType listQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, ListClass.class);
}
Also used : DateClass(com.xpn.xwiki.objects.classes.DateClass) AuthorExecutor(org.xwiki.security.authorization.AuthorExecutor) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) ClassPropertyReference(org.xwiki.model.reference.ClassPropertyReference) Before(org.junit.Before)

Example 94 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class UIExtensionScriptServiceTest method setUp.

@Before
public void setUp() throws Exception {
    contextComponentManager = mock(ComponentManager.class);
    Provider<ComponentManager> componentManagerProvider = componentManager.registerMockComponent(new DefaultParameterizedType(null, Provider.class, ComponentManager.class), "context");
    when(componentManagerProvider.get()).thenReturn(contextComponentManager);
    this.uiExtensionManager = componentManager.getInstance(UIExtensionManager.class);
}
Also used : ComponentManager(org.xwiki.component.manager.ComponentManager) UIExtensionManager(org.xwiki.uiextension.UIExtensionManager) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) Provider(javax.inject.Provider) Before(org.junit.Before)

Example 95 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class StandardExtendedURLResourceReferenceSerializerTest method serialize.

@Test
public void serialize() throws Exception {
    TestResourceReference resource = new TestResourceReference();
    ResourceReferenceSerializer serializer = mock(ResourceReferenceSerializer.class);
    ComponentManager componentManager = this.mocker.getInstance(ComponentManager.class, "context");
    when(componentManager.getInstance(new DefaultParameterizedType(null, ResourceReferenceSerializer.class, TestResourceReference.class, ExtendedURL.class), "standard")).thenReturn(serializer);
    this.mocker.getComponentUnderTest().serialize(resource);
    // Verify the serializer is called and with the proper parameters
    verify(serializer).serialize(same(resource));
}
Also used : ResourceReferenceSerializer(org.xwiki.resource.ResourceReferenceSerializer) ComponentManager(org.xwiki.component.manager.ComponentManager) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) ExtendedURL(org.xwiki.url.ExtendedURL) Test(org.junit.Test)

Aggregations

DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)104 Test (org.junit.Test)44 Before (org.junit.Before)32 Provider (javax.inject.Provider)27 DocumentReference (org.xwiki.model.reference.DocumentReference)24 XWikiContext (com.xpn.xwiki.XWikiContext)19 ComponentManager (org.xwiki.component.manager.ComponentManager)19 ExecutionContext (org.xwiki.context.ExecutionContext)17 ExtendedURL (org.xwiki.url.ExtendedURL)15 Execution (org.xwiki.context.Execution)14 HashMap (java.util.HashMap)13 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)13 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)12 ResourceReferenceSerializer (org.xwiki.resource.ResourceReferenceSerializer)10 VfsResourceReference (org.xwiki.vfs.VfsResourceReference)10 Properties (java.util.Properties)9 MimeBodyPartFactory (org.xwiki.mail.MimeBodyPartFactory)9 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)8 XWiki (com.xpn.xwiki.XWiki)7 File (java.io.File)7