use of com.enonic.xp.macro.MacroDescriptors in project xp by enonic.
the class ApplicationInfoServiceImplTest method testMacros.
@Test
public void testMacros() {
mockMacros(this.applicationKey);
final MacroDescriptors macros = this.service.getMacroDescriptors(this.applicationKey);
assertEquals(macros.getSize(), 2);
}
use of com.enonic.xp.macro.MacroDescriptors in project xp by enonic.
the class ApplicationInfoServiceImplTest method mockMacros.
private void mockMacros(final ApplicationKey applicationKey) {
final MacroDescriptor macroDescriptor1 = MacroDescriptor.create().key(MacroKey.from("my-app1:macro1")).description("my description").displayName("A macro").form(Form.create().build()).build();
final MacroDescriptor macroDescriptor2 = MacroDescriptor.create().key(MacroKey.from("my-app2:macro2")).description("my description").displayName("B macro").form(Form.create().build()).build();
final MacroDescriptors macroDescriptors = MacroDescriptors.from(macroDescriptor1, macroDescriptor2);
Mockito.when(this.macroDescriptorService.getByApplications(ApplicationKeys.from(applicationKey, ApplicationKey.SYSTEM))).thenReturn(macroDescriptors);
}
use of com.enonic.xp.macro.MacroDescriptors in project xp by enonic.
the class MacroInstruction method resolveMacroDescriptorCaseInsensitive.
private MacroDescriptor resolveMacroDescriptorCaseInsensitive(final SiteConfigs siteConfigs, final String macroName) {
for (SiteConfig siteConfig : siteConfigs) {
final MacroDescriptors macroDescriptors = macroDescriptorService.getByApplication(siteConfig.getApplicationKey());
final MacroDescriptor macroDescriptor = macroDescriptors.stream().filter((md) -> md.getName().equalsIgnoreCase(macroName)).findFirst().orElse(null);
if (macroDescriptor != null) {
return macroDescriptor;
}
}
return null;
}
Aggregations