use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class XmlSiteParserTest method testSiteXmlDeserializationWithMappings.
@Test
public void testSiteXmlDeserializationWithMappings() {
final String xml = loadTestXml("serialized-site-with-mappings.xml");
final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
ApplicationKey applicationKey = ApplicationKey.from("myapplication");
this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
assertEquals(1, siteDescriptor.getForm().getFormItems().size());
assertEquals(2, siteDescriptor.getXDataMappings().getSize());
assertEquals(2, siteDescriptor.getResponseProcessors().getSize());
assertEquals(3, siteDescriptor.getMappingDescriptors().getSize());
final ControllerMappingDescriptor mapping1 = siteDescriptor.getMappingDescriptors().get(0);
final ControllerMappingDescriptor mapping2 = siteDescriptor.getMappingDescriptors().get(1);
final ControllerMappingDescriptor mapping3 = siteDescriptor.getMappingDescriptors().get(2);
assertEquals("myapplication:/site/page/person/person.js", mapping1.getController().toString());
assertNull(mapping1.getContentConstraint());
assertEquals("/person/*", mapping1.getPattern().toString());
assertEquals(10, mapping1.getOrder());
assertEquals("myapplication:/controller1.js", mapping2.getController().toString());
assertEquals("_path:'/*/fisk'", mapping2.getContentConstraint().toString());
assertEquals("/.*", mapping2.getPattern().toString());
assertEquals(50, mapping2.getOrder());
assertEquals("myapplication:/controller2.js", mapping3.getController().toString());
assertEquals("type:'portal:fragment'", mapping3.getContentConstraint().toString());
assertEquals("/.*", mapping3.getPattern().toString());
assertEquals(5, mapping3.getOrder());
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class XmlSiteParserTest method testSiteXmlDeserialization.
@Test
public void testSiteXmlDeserialization() {
final String xml = loadTestXml("serialized-site.xml");
final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
ApplicationKey applicationKey = ApplicationKey.from("myapplication");
this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
assertEquals(1, siteDescriptor.getForm().getFormItems().size());
assertEquals(2, siteDescriptor.getXDataMappings().getSize());
assertEquals(2, siteDescriptor.getResponseProcessors().getSize());
assertEquals(0, siteDescriptor.getMappingDescriptors().getSize());
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class LocaleServiceImplTest method bundleInvalidateCaching.
@Test
public void bundleInvalidateCaching() {
final ResourceKeys resourceKeys = ResourceKeys.empty();
when(resourceService.findFiles(any(), anyString())).thenReturn(resourceKeys);
final ApplicationKey myApp = ApplicationKey.from("myapplication");
final ApplicationKey otherApp = ApplicationKey.from("otherapp");
MessageBundle bundleCached = localeService.getBundle(myApp, Locale.ENGLISH, "/phrases", "/override");
MessageBundle bundle = localeService.getBundle(myApp, Locale.ENGLISH, "/phrases", "/override");
MessageBundle otherBundleCached = localeService.getBundle(otherApp, Locale.ENGLISH, "/texts");
MessageBundle otherBundle = localeService.getBundle(otherApp, Locale.ENGLISH, "/texts");
assertSame(bundle, bundleCached);
assertSame(otherBundle, otherBundleCached);
Application application = Mockito.mock(Application.class);
when(application.getKey()).thenReturn(myApp);
localeService.activated(application);
bundle = localeService.getBundle(myApp, Locale.ENGLISH, "/phrases", "/override");
otherBundle = localeService.getBundle(otherApp, Locale.ENGLISH, "/texts");
assertNotSame(bundle, bundleCached);
assertSame(otherBundle, otherBundleCached);
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class StyleDescriptorServiceImplTest method getAll.
@Test
public void getAll() {
final ApplicationKey appKey = ApplicationKey.from("myapp1");
final StyleDescriptors descriptors = this.service.getAll();
assertNotNull(descriptors);
assertEquals(2, descriptors.getSize());
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class LocaleScriptBean method getMessageBundle.
private MessageBundle getMessageBundle(final String locale, final String... bundleNames) {
final ApplicationKey applicationKey = getApplication();
final Locale resolvedLocale = resolveLocale(locale);
return this.localeService.get().getBundle(applicationKey, resolvedLocale, bundleNames);
}
Aggregations