test_class.declarator: EVENT_ID = 1
test_class.modifier: public static final
test_class.original_string: public static final long EVENT_ID = 1;
test_class.type: long
test_class.var_name: EVENT_ID
test_class.declarator: USER_ID = 1
test_class.modifier: public static final
test_class.original_string: public static final long USER_ID = 1;
test_class.type: long
test_class.var_name: USER_ID
test_class.declarator: ACCOUNT_ID = 1
test_class.modifier: public static final
test_class.original_string: public static final long ACCOUNT_ID = 1;
test_class.type: long
test_class.var_name: ACCOUNT_ID
test_class.declarator: staticFieldValues = new HashMap<>()
test_class.modifier: protected
test_class.original_string: protected Map<String, Object> staticFieldValues = new HashMap<>();
test_class.type: Map<String, Object>
test_class.var_name: staticFieldValues
test_class.declarator: publishedEvents = new ArrayList<>()
test_class.modifier: protected
test_class.original_string: protected List<Event> publishedEvents = new ArrayList<>();
test_class.type: List<Event>
test_class.var_name: publishedEvents
test_class.declarator: eventDao
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected EventDao eventDao;
test_class.type: EventDao
test_class.var_name: eventDao
test_class.declarator: accountDao
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected AccountDao accountDao;
test_class.type: AccountDao
test_class.var_name: accountDao
test_class.declarator: userDao
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected UserDao userDao;
test_class.type: UserDao
test_class.var_name: userDao
test_class.declarator: projectDao
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected ProjectDao projectDao;
test_class.type: ProjectDao
test_class.var_name: projectDao
test_class.declarator: entityMgr
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected EntityManager entityMgr;
test_class.type: EntityManager
test_class.var_name: entityMgr
test_class.declarator: configDao
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected ConfigurationDao configDao;
test_class.type: ConfigurationDao
test_class.var_name: configDao
test_class.declarator: eventBus
test_class.modifier: @Mock
      protected
test_class.original_string: @Mock
      protected EventBus eventBus;
test_class.type: EventBus
test_class.var_name: eventBus
test_class.file: cosmic-core/server/src/test/java/com/cloud/event/ActionEventUtilsTest.java
test_class.identifier: ActionEventUtilsTest
test_case.body: @Test
      public void testPopulateFirstClassEntities() {
          final AccountVO account = new AccountVO("testaccount", 1L, "networkdomain", (short) 0, "uuid");
          account.setId(ACCOUNT_ID);
          final UserVO user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone",
                  UUID.randomUUID().toString(), User.Source.UNKNOWN);
  
          Mockito.when(accountDao.findById(ACCOUNT_ID)).thenReturn(account);
          Mockito.when(userDao.findById(USER_ID)).thenReturn(user);
  
          CallContext.register(user, account);
  
          //Inject some entity UUIDs into the call context
          final String instanceUuid = UUID.randomUUID().toString();
          final String ipUuid = UUID.randomUUID().toString();
          CallContext.current().putContextParameter(VirtualMachine.class, instanceUuid);
          CallContext.current().putContextParameter(IpAddress.class, ipUuid);
  
          ActionEventUtils.onActionEvent(USER_ID, ACCOUNT_ID, account.getDomainId(), "StaticNat", "Test event");
  
          //Assertions
          Assert.assertNotEquals(publishedEvents.size(), 0);
          Assert.assertEquals(publishedEvents.size(), 1);
  
          final Event event = publishedEvents.get(0);
          Assert.assertNotNull(event.getDescription());
  
          final JsonObject json = new JsonParser().parse(event.getDescription()).getAsJsonObject();
  
          Assert.assertTrue(json.has("VirtualMachine"));
          Assert.assertTrue(json.has("IpAddress"));
          Assert.assertEquals(json.get("VirtualMachine").getAsString(), instanceUuid);
          Assert.assertEquals(json.get("IpAddress").getAsString(), ipUuid);
  
          CallContext.unregister();
      }
test_case.class_method_signature: ActionEventUtilsTest.testPopulateFirstClassEntities()
test_case.full_signature: @Test public void testPopulateFirstClassEntities()
test_case.identifier: testPopulateFirstClassEntities
test_case.invocations: setId toString randomUUID thenReturn when findById thenReturn when findById register toString randomUUID toString randomUUID putContextParameter current putContextParameter current onActionEvent getDomainId assertNotEquals size assertEquals size get assertNotNull getDescription getAsJsonObject parse getDescription assertTrue has assertTrue has assertEquals getAsString get assertEquals getAsString get unregister
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPopulateFirstClassEntities()
focal_class.declarator: EventDetails = "event_details"
focal_class.modifier: public static final
focal_class.original_string: public static final String EventDetails = "event_details";
focal_class.type: String
focal_class.var_name: EventDetails
focal_class.declarator: EventId = "event_id"
focal_class.modifier: public static final
focal_class.original_string: public static final String EventId = "event_id";
focal_class.type: String
focal_class.var_name: EventId
focal_class.declarator: EntityType = "entity_type"
focal_class.modifier: public static final
focal_class.original_string: public static final String EntityType = "entity_type";
focal_class.type: String
focal_class.var_name: EntityType
focal_class.declarator: EntityUuid = "entity_uuid"
focal_class.modifier: public static final
focal_class.original_string: public static final String EntityUuid = "entity_uuid";
focal_class.type: String
focal_class.var_name: EntityUuid
focal_class.declarator: EntityDetails = "entity_details"
focal_class.modifier: public static final
focal_class.original_string: public static final String EntityDetails = "entity_details";
focal_class.type: String
focal_class.var_name: EntityDetails
focal_class.declarator: s_logger = LoggerFactory.getLogger(ActionEventUtils.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger s_logger = LoggerFactory.getLogger(ActionEventUtils.class);
focal_class.type: Logger
focal_class.var_name: s_logger
focal_class.declarator: s_userDao
focal_class.modifier: protected static
focal_class.original_string: protected static UserDao s_userDao;
focal_class.type: UserDao
focal_class.var_name: s_userDao
focal_class.declarator: s_eventBus = null
focal_class.modifier: protected static
focal_class.original_string: protected static EventBus s_eventBus = null;
focal_class.type: EventBus
focal_class.var_name: s_eventBus
focal_class.declarator: s_entityMgr
focal_class.modifier: protected static
focal_class.original_string: protected static EntityManager s_entityMgr;
focal_class.type: EntityManager
focal_class.var_name: s_entityMgr
focal_class.declarator: s_configDao
focal_class.modifier: protected static
focal_class.original_string: protected static ConfigurationDao s_configDao;
focal_class.type: ConfigurationDao
focal_class.var_name: s_configDao
focal_class.declarator: s_eventDao
focal_class.modifier: private static
focal_class.original_string: private static EventDao s_eventDao;
focal_class.type: EventDao
focal_class.var_name: s_eventDao
focal_class.declarator: s_accountDao
focal_class.modifier: private static
focal_class.original_string: private static AccountDao s_accountDao;
focal_class.type: AccountDao
focal_class.var_name: s_accountDao
focal_class.declarator: s_projectDao
focal_class.modifier: private static
focal_class.original_string: private static ProjectDao s_projectDao;
focal_class.type: ProjectDao
focal_class.var_name: s_projectDao
focal_class.declarator: eventDao
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      EventDao eventDao;
focal_class.type: EventDao
focal_class.var_name: eventDao
focal_class.declarator: accountDao
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      AccountDao accountDao;
focal_class.type: AccountDao
focal_class.var_name: accountDao
focal_class.declarator: userDao
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      UserDao userDao;
focal_class.type: UserDao
focal_class.var_name: userDao
focal_class.declarator: projectDao
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      ProjectDao projectDao;
focal_class.type: ProjectDao
focal_class.var_name: projectDao
focal_class.declarator: entityMgr
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      EntityManager entityMgr;
focal_class.type: EntityManager
focal_class.var_name: entityMgr
focal_class.declarator: configDao
focal_class.modifier: @Inject
focal_class.original_string: @Inject
      ConfigurationDao configDao;
focal_class.type: ConfigurationDao
focal_class.var_name: configDao
focal_class.file: cosmic-core/server/src/main/java/com/cloud/event/ActionEventUtils.java
focal_class.identifier: ActionEventUtils
focal_class.class_method_signature: ActionEventUtils.ActionEventUtils()
focal_class.full_signature: public  ActionEventUtils()
focal_class.identifier: ActionEventUtils
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  ActionEventUtils()
focal_class.class_method_signature: ActionEventUtils.onActionEvent(final Long userId, final Long accountId, final Long domainId, final String type, final String description)
focal_class.full_signature: public static Long onActionEvent(final Long userId, final Long accountId, final Long domainId, final String type, final String description)
focal_class.identifier: onActionEvent
focal_class.modifiers: public static
focal_class.parameters: (final Long userId, final Long accountId, final Long domainId, final String type, final String description)
focal_class.return: Long
focal_class.signature: Long onActionEvent(final Long userId, final Long accountId, final Long domainId, final String type, final String description)
focal_class.class_method_signature: ActionEventUtils.publishOnEventBus(final long userId, final long accountId, final String eventCategory, final String eventType, final Event.State state, final String
              description)
focal_class.full_signature: private static void publishOnEventBus(final long userId, final long accountId, final String eventCategory, final String eventType, final Event.State state, final String
              description)
focal_class.identifier: publishOnEventBus
focal_class.modifiers: private static
focal_class.parameters: (final long userId, final long accountId, final String eventCategory, final String eventType, final Event.State state, final String
              description)
focal_class.return: void
focal_class.signature: void publishOnEventBus(final long userId, final long accountId, final String eventCategory, final String eventType, final Event.State state, final String
              description)
focal_class.class_method_signature: ActionEventUtils.persistActionEvent(final Long userId, final Long accountId, final Long domainId, final String level, final String type,
                                              final Event.State state, final boolean eventDisplayEnabled, final String description, final Long startEventId)
focal_class.full_signature: private static Event persistActionEvent(final Long userId, final Long accountId, final Long domainId, final String level, final String type,
                                              final Event.State state, final boolean eventDisplayEnabled, final String description, final Long startEventId)
focal_class.identifier: persistActionEvent
focal_class.modifiers: private static
focal_class.parameters: (final Long userId, final Long accountId, final Long domainId, final String level, final String type,
                                              final Event.State state, final boolean eventDisplayEnabled, final String description, final Long startEventId)
focal_class.return: Event
focal_class.signature: Event persistActionEvent(final Long userId, final Long accountId, final Long domainId, final String level, final String type,
                                              final Event.State state, final boolean eventDisplayEnabled, final String description, final Long startEventId)
focal_class.class_method_signature: ActionEventUtils.getEntityUuid(final Class<?> entityType, final Object entityId)
focal_class.full_signature: private static String getEntityUuid(final Class<?> entityType, final Object entityId)
focal_class.identifier: getEntityUuid
focal_class.modifiers: private static
focal_class.parameters: (final Class<?> entityType, final Object entityId)
focal_class.return: String
focal_class.signature: String getEntityUuid(final Class<?> entityType, final Object entityId)
focal_class.class_method_signature: ActionEventUtils.populateFirstClassEntities(final Map<String, String> eventDescription)
focal_class.full_signature: private static void populateFirstClassEntities(final Map<String, String> eventDescription)
focal_class.identifier: populateFirstClassEntities
focal_class.modifiers: private static
focal_class.parameters: (final Map<String, String> eventDescription)
focal_class.return: void
focal_class.signature: void populateFirstClassEntities(final Map<String, String> eventDescription)
focal_class.class_method_signature: ActionEventUtils.getDomainId(final long accountId)
focal_class.full_signature: private static long getDomainId(final long accountId)
focal_class.identifier: getDomainId
focal_class.modifiers: private static
focal_class.parameters: (final long accountId)
focal_class.return: long
focal_class.signature: long getDomainId(final long accountId)
focal_class.class_method_signature: ActionEventUtils.onScheduledActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
              startEventId)
focal_class.full_signature: public static Long onScheduledActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
              startEventId)
focal_class.identifier: onScheduledActionEvent
focal_class.modifiers: public static
focal_class.parameters: (final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
              startEventId)
focal_class.return: Long
focal_class.signature: Long onScheduledActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
              startEventId)
focal_class.class_method_signature: ActionEventUtils.startNestedActionEvent(final String eventType, final String eventDescription)
focal_class.full_signature: public static void startNestedActionEvent(final String eventType, final String eventDescription)
focal_class.identifier: startNestedActionEvent
focal_class.modifiers: public static
focal_class.parameters: (final String eventType, final String eventDescription)
focal_class.return: void
focal_class.signature: void startNestedActionEvent(final String eventType, final String eventDescription)
focal_class.class_method_signature: ActionEventUtils.onStartedActionEventFromContext(final String eventType, final String eventDescription, final boolean eventDisplayEnabled)
focal_class.full_signature: public static void onStartedActionEventFromContext(final String eventType, final String eventDescription, final boolean eventDisplayEnabled)
focal_class.identifier: onStartedActionEventFromContext
focal_class.modifiers: public static
focal_class.parameters: (final String eventType, final String eventDescription, final boolean eventDisplayEnabled)
focal_class.return: void
focal_class.signature: void onStartedActionEventFromContext(final String eventType, final String eventDescription, final boolean eventDisplayEnabled)
focal_class.class_method_signature: ActionEventUtils.onStartedActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
              startEventId)
focal_class.full_signature: public static Long onStartedActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
              startEventId)
focal_class.identifier: onStartedActionEvent
focal_class.modifiers: public static
focal_class.parameters: (final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
              startEventId)
focal_class.return: Long
focal_class.signature: Long onStartedActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
              startEventId)
focal_class.class_method_signature: ActionEventUtils.onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final String description, final long startEventId)
focal_class.full_signature: public static Long onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final String description, final long startEventId)
focal_class.identifier: onCompletedActionEvent
focal_class.modifiers: public static
focal_class.parameters: (final Long userId, final Long accountId, final String level, final String type, final String description, final long startEventId)
focal_class.return: Long
focal_class.signature: Long onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final String description, final long startEventId)
focal_class.class_method_signature: ActionEventUtils.onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
              description, final long startEventId)
focal_class.full_signature: public static Long onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
              description, final long startEventId)
focal_class.identifier: onCompletedActionEvent
focal_class.modifiers: public static
focal_class.parameters: (final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
              description, final long startEventId)
focal_class.return: Long
focal_class.signature: Long onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
              description, final long startEventId)
focal_class.class_method_signature: ActionEventUtils.onCreatedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
              description)
focal_class.full_signature: public static Long onCreatedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
              description)
focal_class.identifier: onCreatedActionEvent
focal_class.modifiers: public static
focal_class.parameters: (final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
              description)
focal_class.return: Long
focal_class.signature: Long onCreatedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
              description)
focal_class.class_method_signature: ActionEventUtils.init()
focal_class.full_signature: @PostConstruct void init()
focal_class.identifier: init
focal_class.modifiers: @PostConstruct
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void init()
focal_method.body: private static void populateFirstClassEntities(final Map<String, String> eventDescription) {
  
          final CallContext context = CallContext.current();
          final Map<Object, Object> contextMap = context.getContextParameters();
  
          for (final Map.Entry<Object, Object> entry : contextMap.entrySet()) {
              try {
                  final Class<?> clz = (Class<?>) entry.getKey();
                  if (clz != null && Identity.class.isAssignableFrom(clz)) {
                      final String uuid = getEntityUuid(clz, entry.getValue());
                      eventDescription.put(ReflectUtil.getEntityName(clz), uuid);
                  }
              } catch (final Exception e) {
                  s_logger.trace("Caught exception while populating first class entities for event bus, moving on");
              }
          }
      }
focal_method.class_method_signature: ActionEventUtils.populateFirstClassEntities(final Map<String, String> eventDescription)
focal_method.full_signature: private static void populateFirstClassEntities(final Map<String, String> eventDescription)
focal_method.identifier: populateFirstClassEntities
focal_method.invocations: current getContextParameters entrySet getKey isAssignableFrom getEntityUuid getValue put getEntityName trace
focal_method.modifiers: private static
focal_method.parameters: (final Map<String, String> eventDescription)
focal_method.return: void
focal_method.signature: void populateFirstClassEntities(final Map<String, String> eventDescription)