IspnDefinitionsServiceImpl implements DefinitionsService { private List<ActionDefinition> getActionDefinitions(String tenantId) throws Exception { List<IspnActionDefinition> actionDefinitions = queryFactory.from(IspnActionDefinition.class) .having("tenantId") .eq(tenantId) .build() .list(); return actionDefinitions.stream().map(a -> a.getActionDefinition()).collect(Collectors.toList()); }  void init(); void setAlertsEngine(AlertsEngine alertsEngine); void setAlertsContext(AlertsContext alertsContext); void setProperties(PropertiesService properties); @Override void addActionDefinition(String tenantId, ActionDefinition actionDefinition); @Override void addTrigger(String tenantId, Trigger trigger); @Override void addGroupTrigger(String tenantId, Trigger groupTrigger); @Override Trigger addMemberTrigger(String tenantId, String groupId, String memberId, String memberName,
            String memberDescription, Map<String, String> memberContext, Map<String, String> memberTags,
            Map<String, String> dataIdMap); @Override Trigger addDataDrivenMemberTrigger(String tenantId, String groupId, String source); @Override void removeTrigger(String tenantId, String triggerId); @Override void removeGroupTrigger(String tenantId, String groupId, boolean keepNonOrphans, boolean keepOrphans); @Override void updateFullTrigger(String tenantId, FullTrigger fullTrigger); @Override Trigger updateTrigger(String tenantId, Trigger trigger); @Override Trigger updateGroupTrigger(String tenantId, Trigger groupTrigger); @Override void updateGroupTriggerEnablement(String tenantId, String groupTriggerIds, boolean enabled); @Override void updateTriggerEnablement(String tenantId, String triggerIds, boolean enabled); @Override Trigger getTrigger(String tenantId, String triggerId); @Override Page<Trigger> getTriggers(String tenantId, TriggersCriteria criteria, Pager pager); @Override Collection<Trigger> getMemberTriggers(String tenantId, String groupId, boolean includeOrphans); @Override Collection<Trigger> getAllTriggers(); @Override Collection<Trigger> getAllTriggersByTag(String name, String value); @Override Trigger orphanMemberTrigger(String tenantId, String memberId); @Override Trigger unorphanMemberTrigger(String tenantId, String memberId, Map<String, String> memberContext,
            Map<String, String> memberTags, Map<String, String> dataIdMap); @Override Dampening addDampening(String tenantId, Dampening dampening); @Override Dampening addGroupDampening(String tenantId, Dampening groupDampening); @Override void removeDampening(String tenantId, String dampeningId); @Override void removeGroupDampening(String tenantId, String groupDampeningId); @Override Dampening updateDampening(String tenantId, Dampening dampening); @Override Dampening updateGroupDampening(String tenantId, Dampening groupDampening); @Override Dampening getDampening(String tenantId, String dampeningId); @Override Collection<Dampening> getAllDampenings(); @Override Collection<Dampening> getDampenings(String tenantId); @Override Collection<Dampening> getTriggerDampenings(String tenantId, String triggerId, Mode triggerMode); @Override Collection<Condition> setConditions(String tenantId, String triggerId, Mode triggerMode,
            Collection<Condition> conditions); @Override Collection<Condition> setAllConditions(String tenantId, String triggerId,
            Collection<Condition> conditions); @Override Collection<Condition> setGroupConditions(String tenantId, String groupId, Mode triggerMode,
            Collection<Condition> groupConditions, Map<String, Map<String, String>> dataIdMemberMap); @Override Collection<Condition> getAllConditions(); @Override Collection<Condition> getConditions(String tenantId); @Override Collection<Condition> getTriggerConditions(String tenantId, String triggerId, Mode triggerMode); @Override void addActionPlugin(String actionPlugin, Set<String> properties); @Override void addActionPlugin(String actionPlugin, Map<String, String> defaultProperties); @Override void removeActionPlugin(String actionPlugin); @Override void updateActionPlugin(String actionPlugin, Set<String> properties); @Override void updateActionPlugin(String actionPlugin, Map<String, String> defaultProperties); @Override Collection<String> getActionPlugins(); @Override Set<String> getActionPlugin(String actionPlugin); @Override Map<String, String> getDefaultActionPlugin(String actionPlugin); @Override void removeActionDefinition(String tenantId, String actionPlugin, String actionId); @Override void updateActionDefinition(String tenantId, ActionDefinition actionDefinition); @Override Map<String, Map<String, Set<String>>> getAllActionDefinitionIds(); @Override Collection<ActionDefinition> getAllActionDefinitions(); @Override Map<String, Set<String>> getActionDefinitionIds(String tenantId); @Override Collection<String> getActionDefinitionIds(String tenantId, String actionPlugin); @Override ActionDefinition getActionDefinition(String tenantId, String actionPlugin, String actionId); @Override void registerListener(DefinitionsListener listener, DefinitionsEvent.Type eventType,
            DefinitionsEvent.Type... eventTypes); @Override void registerDistributedListener(DistributedListener listener); @Override Definitions exportDefinitions(String tenantId); @Override Definitions importDefinitions(String tenantId, Definitions definitions, ImportType strategy); @Override void createFullTrigger(String tenantId, FullTrigger fullTrigger); @Override FullTrigger getFullTrigger(String tenantId, String triggerId);  }
@Test public void getActionDefinitions() throws Exception { int numTenants = 2; int numPlugins = 2; int numActions = 4; createTestPluginsAndActions(numTenants, numPlugins, numActions); assertEquals(2 * 2 * 4, definitions.getAllActionDefinitions().size()); Map<String, Map<String, Set<String>>> actionIds = definitions.getAllActionDefinitionIds(); assertEquals(numTenants, actionIds.keySet().size()); assertEquals(numPlugins, actionIds.get("tenant0").keySet().size()); assertEquals(numActions, actionIds.get("tenant0").get("plugin0").size()); Map<String, Set<String>> actionIdsByTenant = definitions.getActionDefinitionIds("tenant1"); assertEquals(numPlugins, actionIdsByTenant.keySet().size()); Collection<String> actionIdsByTenantAndPlugin = definitions.getActionDefinitionIds("tenant1", "plugin1"); assertEquals(numActions, actionIdsByTenantAndPlugin.size()); deleteTestPluginsAndActions(numTenants, numPlugins, numActions); }