Search in sources :

Example 6 with MacroDescriptors

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);
}
Also used : MacroDescriptors(com.enonic.xp.macro.MacroDescriptors) Test(org.junit.jupiter.api.Test)

Example 7 with MacroDescriptors

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);
}
Also used : MacroDescriptor(com.enonic.xp.macro.MacroDescriptor) MacroDescriptors(com.enonic.xp.macro.MacroDescriptors)

Example 8 with 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;
}
Also used : MacroDescriptor(com.enonic.xp.macro.MacroDescriptor) SiteConfig(com.enonic.xp.site.SiteConfig) MacroDescriptors(com.enonic.xp.macro.MacroDescriptors)

Aggregations

MacroDescriptors (com.enonic.xp.macro.MacroDescriptors)8 Test (org.junit.jupiter.api.Test)5 MacroDescriptor (com.enonic.xp.macro.MacroDescriptor)3 Application (com.enonic.xp.app.Application)1 SiteConfig (com.enonic.xp.site.SiteConfig)1 LinkedHashSet (java.util.LinkedHashSet)1