@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); 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"); 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(); }
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"); } } }
ActionEventUtils { 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"); } } } }
ActionEventUtils { 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"); } } } ActionEventUtils(); }
ActionEventUtils { 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"); } } } ActionEventUtils(); static Long onActionEvent(final Long userId, final Long accountId, final Long domainId, final String type, final String description); static Long onScheduledActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
            startEventId); static void startNestedActionEvent(final String eventType, final String eventDescription); static void onStartedActionEventFromContext(final String eventType, final String eventDescription, final boolean eventDisplayEnabled); static Long onStartedActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
            startEventId); static Long onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final String description, final long startEventId); static Long onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
            description, final long startEventId); static Long onCreatedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
            description); }
ActionEventUtils { 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"); } } } ActionEventUtils(); static Long onActionEvent(final Long userId, final Long accountId, final Long domainId, final String type, final String description); static Long onScheduledActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
            startEventId); static void startNestedActionEvent(final String eventType, final String eventDescription); static void onStartedActionEventFromContext(final String eventType, final String eventDescription, final boolean eventDisplayEnabled); static Long onStartedActionEvent(final Long userId, final Long accountId, final String type, final String description, final boolean eventDisplayEnabled, final long
            startEventId); static Long onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final String description, final long startEventId); static Long onCompletedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
            description, final long startEventId); static Long onCreatedActionEvent(final Long userId, final Long accountId, final String level, final String type, final boolean eventDisplayEnabled, final String
            description); static final String EventDetails; static final String EventId; static final String EntityType; static final String EntityUuid; static final String EntityDetails; }