use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class AbstractListClassPropertyValuesProviderTest method addProperty.
protected void addProperty(String name, PropertyClass definition, boolean withQueryBuilders) throws Exception {
XWiki xwiki = this.xcontext.getWiki();
BaseClass xclass = this.classDocument.getXClass();
ClassPropertyReference propertyReference = new ClassPropertyReference(name, this.classReference);
when(xwiki.getDocument(propertyReference, this.xcontext)).thenReturn(this.classDocument);
when(xclass.get(name)).thenReturn(definition);
definition.setOwnerDocument(this.classDocument);
if (withQueryBuilders) {
DefaultParameterizedType allowedValuesQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, definition.getClass());
QueryBuilder allowedValuesQueryBuilder = getMocker().getInstance(allowedValuesQueryBuilderType);
when(allowedValuesQueryBuilder.build(definition)).thenReturn(this.allowedValuesQuery);
if (definition instanceof ListClass) {
DefaultParameterizedType usedValuesQueryBuilderType = new DefaultParameterizedType(null, QueryBuilder.class, ListClass.class);
this.usedValuesQueryBuilder = getMocker().getInstance(usedValuesQueryBuilderType, "usedValues");
when(this.usedValuesQueryBuilder.build((ListClass) definition)).thenReturn(this.usedValuesQuery);
}
}
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class FilesystemResourceReferenceSerializerTest method serializeCSSResourceWithURLsInIt.
@Test
public void serializeCSSResourceWithURLsInIt() throws Exception {
FilesystemExportContext exportContext = new FilesystemExportContext();
exportContext.setExportDir(BASEDIR);
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", "css/font-awesome.min.css"));
assertEquals("webjars/font-awesome/4.7.0/css/font-awesome.min.css", this.mocker.getComponentUnderTest().serialize(reference).serialize());
// Also verify that the resources haves been copied!
assertTrue(new File(BASEDIR, "webjars/font-awesome/4.7.0/css/font-awesome.min.css").exists());
assertTrue(new File(BASEDIR, "webjars/font-awesome/4.7.0/fonts/fontawesome-webfont.eot").exists());
assertTrue(new File(BASEDIR, "webjars/font-awesome/4.7.0/fonts/fontawesome-webfont.woff2").exists());
assertTrue(new File(BASEDIR, "webjars/font-awesome/4.7.0/fonts/fontawesome-webfont.woff").exists());
assertTrue(new File(BASEDIR, "webjars/font-awesome/4.7.0/fonts/fontawesome-webfont.svg").exists());
assertTrue(new File(BASEDIR, "webjars/font-awesome/4.7.0/fonts/fontawesome-webfont.ttf").exists());
}
use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.
the class FilesystemResourceReferenceSerializerTest method serializeWithCSSPathAdjustments.
@Test
public void serializeWithCSSPathAdjustments() throws Exception {
FilesystemExportContext exportContext = new FilesystemExportContext();
exportContext.setExportDir(BASEDIR);
exportContext.pushCSSParentLevels(3);
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 FilesystemResourceReferenceSerializerTest method serialize.
@Test
public void serialize() throws Exception {
FilesystemExportContext exportContext = new FilesystemExportContext();
exportContext.setExportDir(BASEDIR);
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 WebJarsResourceReferenceSerializerTest method serialize.
@Test
public void serialize() throws Exception {
URLNormalizer<ExtendedURL> normalizer = this.mocker.getInstance(new DefaultParameterizedType(null, URLNormalizer.class, ExtendedURL.class), "contextpath");
Map<String, List<String>> parameters = new HashMap<>();
parameters.put("key1", Arrays.asList("value1"));
parameters.put("key2", Arrays.asList("value2", "value3"));
ExtendedURL partialURL = new ExtendedURL(Arrays.asList("webjars", "namespace", "one", "two"), parameters);
ExtendedURL expectedURL = new ExtendedURL(Arrays.asList("xwiki", "webjars", "namespace", "one", "two"), parameters);
when(normalizer.normalize(partialURL)).thenReturn(expectedURL);
WebJarsResourceReference reference = new WebJarsResourceReference("namespace", Arrays.asList("one", "two"));
reference.addParameter("key1", "value1");
reference.addParameter("key2", new String[] { "value2", "value3" });
assertEquals(expectedURL, this.mocker.getComponentUnderTest().serialize(reference));
}
Aggregations