Search in sources :

Example 1 with MacroDescriptors

use of com.enonic.xp.macro.MacroDescriptors in project xp by enonic.

the class MacroDescriptorServiceTest method testGetByApplications.

@Test
public void testGetByApplications() throws Exception {
    final MacroDescriptors result = this.service.getByApplications(ApplicationKeys.from("myapp1", "myapp2", ApplicationKey.SYSTEM.getName()));
    assertNotNull(result);
    assertEquals(4, result.getSize());
}
Also used : MacroDescriptors(com.enonic.xp.macro.MacroDescriptors) Test(org.junit.jupiter.api.Test)

Example 2 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 3 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 4 with MacroDescriptors

use of com.enonic.xp.macro.MacroDescriptors in project xp by enonic.

the class MacroDescriptorServiceImpl method getAll.

@Override
public MacroDescriptors getAll() {
    final Set<MacroDescriptor> set = new LinkedHashSet<>(builtinMacrosDescriptors.getAll().getSet());
    for (final Application application : this.applicationService.getInstalledApplications()) {
        final MacroDescriptors macroDescriptors = getByApplication(application.getKey());
        set.addAll(macroDescriptors.getSet());
    }
    return MacroDescriptors.from(set);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) MacroDescriptor(com.enonic.xp.macro.MacroDescriptor) Application(com.enonic.xp.app.Application) MacroDescriptors(com.enonic.xp.macro.MacroDescriptors)

Example 5 with MacroDescriptors

use of com.enonic.xp.macro.MacroDescriptors in project xp by enonic.

the class MacroDescriptorServiceTest method testGetBySystemApplication.

@Test
public void testGetBySystemApplication() throws Exception {
    final MacroDescriptors result = this.service.getByApplication(ApplicationKey.SYSTEM);
    assertNotNull(result);
    assertEquals(2, result.getSize());
}
Also used : MacroDescriptors(com.enonic.xp.macro.MacroDescriptors) Test(org.junit.jupiter.api.Test)

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