use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class FilesystemResourceReferenceSerializerTest method serializeWithCSSPathAdjustmentsWithDocParentLevels.
@Test
public void serializeWithCSSPathAdjustmentsWithDocParentLevels() throws Exception {
FilesystemExportContext exportContext = new FilesystemExportContext();
exportContext.setExportDir(BASEDIR);
exportContext.setDocParentLevels(2);
Provider<FilesystemExportContext> exportContextProvider = this.mocker.getInstance(new DefaultParameterizedType(null, Provider.class, FilesystemExportContext.class));
Mockito.when(exportContextProvider.get()).thenReturn(exportContext);
WebJarsResourceReference reference = new WebJarsResourceReference("wiki:wiki", Arrays.asList("font-awesome", "4.7.0", "fonts/FontAwesome.otf"));
// Verify that the returned URL is ok
assertEquals("../../webjars/font-awesome/4.7.0/fonts/FontAwesome.otf", this.mocker.getComponentUnderTest().serialize(reference).serialize());
// Also verify that the resource has been copied!
assertTrue(new File(BASEDIR, "webjars/font-awesome/4.7.0/fonts/FontAwesome.otf").exists());
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class NotificationPreferenceScriptServiceTest method setUp.
@Before
public void setUp() throws Exception {
notificationPreferenceManager = mocker.getInstance(NotificationPreferenceManager.class);
documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
authorizationManager = mocker.getInstance(ContextualAuthorizationManager.class);
targetableNotificationPreferenceBuilderProvider = mock(Provider.class);
when(targetableNotificationPreferenceBuilderProvider.get()).thenReturn(new DefaultTargetableNotificationPreferenceBuilder());
mocker.registerComponent(new DefaultParameterizedType(null, Provider.class, TargetableNotificationPreferenceBuilder.class), targetableNotificationPreferenceBuilderProvider);
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class DBListClass method getDBList.
public List<ListItem> getDBList(XWikiContext context) {
List<ListItem> list = getCachedDBList(context);
if (list == null) {
try {
DefaultParameterizedType dbListQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, DBListClass.class);
QueryBuilder<DBListClass> dbListQueryBuilder = Utils.getComponent(dbListQueryBuilderType);
// Execute the query with the rights of the class last author.
AuthorExecutor authorExecutor = Utils.getComponent(AuthorExecutor.class);
list = makeList(authorExecutor.call(() -> {
return dbListQueryBuilder.build(this).execute();
}, getOwnerDocument().getAuthorReference()));
} catch (Exception e) {
LOGGER.warn("Failed to get the Database List values. Root cause is [{}].", ExceptionUtils.getRootCauseMessage(e));
list = new ArrayList<>();
}
setCachedDBList(list, context);
}
return list;
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class DefaultDBListQueryBuilderTest method build.
@Test
public void build() throws Exception {
DBListClass dbListClass = new DBListClass();
DefaultParameterizedType dbListQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, DBListClass.class);
QueryBuilder<DBListClass> explicitlyAllowedValuesQueryBuilder = this.mocker.getInstance(dbListQueryBuilderType, "explicitlyAllowedValues");
QueryBuilder<DBListClass> implicitlyAllowedValuesQueryBuilder = this.mocker.getInstance(dbListQueryBuilderType, "implicitlyAllowedValues");
Query explicitlyAllowedValuesQuery = mock(Query.class, "explicit");
when(explicitlyAllowedValuesQueryBuilder.build(dbListClass)).thenReturn(explicitlyAllowedValuesQuery);
Query implicitlyAllowedValuesQuery = mock(Query.class, "implicit");
when(implicitlyAllowedValuesQueryBuilder.build(dbListClass)).thenReturn(implicitlyAllowedValuesQuery);
assertSame(implicitlyAllowedValuesQuery, this.mocker.getComponentUnderTest().build(dbListClass));
dbListClass.setSql("test");
assertSame(explicitlyAllowedValuesQuery, this.mocker.getComponentUnderTest().build(dbListClass));
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class WikiTemplateMigrationTest method setUp.
@Before
public void setUp() throws Exception {
wikiDescriptorManager = mocker.getInstance(WikiDescriptorManager.class);
queryManager = mocker.getInstance(QueryManager.class);
// documentReferenceResolver = mocker.getInstance(DocumentReferenceResolver.TYPE_STRING, "current");
documentReferenceResolver = mocker.getInstance(new DefaultParameterizedType(null, DocumentReferenceResolver.class, String.class));
execution = mock(Execution.class);
mocker.registerComponent(Execution.class, execution);
xcontext = mock(XWikiContext.class);
xwiki = mock(XWiki.class);
ExecutionContext executionContext = mock(ExecutionContext.class);
when(execution.getContext()).thenReturn(executionContext);
when(executionContext.getProperty("xwikicontext")).thenReturn(xcontext);
when(xcontext.getWiki()).thenReturn(xwiki);
when(wikiDescriptorManager.getMainWikiId()).thenReturn("mainWiki");
query = mock(Query.class);
when(queryManager.createQuery(any(), eq(Query.XWQL))).thenReturn(query);
}
Aggregations