AlertPublishEvent { public static AlertPublishEvent createAlertPublishEvent(AlertStreamEvent event) { Preconditions.checkNotNull(event.getAlertId(), "alertId is not initialized before being published: " + event.toString()); AlertPublishEvent alertEvent = new AlertPublishEvent(); alertEvent.setAlertId(event.getAlertId()); alertEvent.setPolicyId(event.getPolicyId()); alertEvent.setAlertTimestamp(event.getCreatedTime()); alertEvent.setStreamId(event.getStreamId()); alertEvent.setCreatedBy(event.getCreatedBy()); alertEvent.setCreatedTime(event.getCreatedTime()); alertEvent.setAlertSubject(event.getSubject()); alertEvent.setAlertBody(event.getBody()); if (event.getContext() != null && !event.getContext().isEmpty()) { if (event.getContext().containsKey(SITE_ID_KEY)) { alertEvent.setSiteId(event.getContext().get(SITE_ID_KEY).toString()); } if (event.getContext().containsKey(POLICY_VALUE_KEY)) { alertEvent.setPolicyValue(event.getContext().get(POLICY_VALUE_KEY).toString()); } if (event.getContext().containsKey(APP_IDS_KEY)) { alertEvent.setAppIds((List<String>) event.getContext().get(APP_IDS_KEY)); } } alertEvent.setAlertData(event.getDataMap()); return alertEvent; }  String getAlertId(); void setAlertId(String alertId); List<String> getAppIds(); void setAppIds(List<String> appIds); String getPolicyValue(); void setPolicyValue(String policyValue); long getAlertTimestamp(); void setAlertTimestamp(long alertTimestamp); String getSiteId(); void setSiteId(String siteId); String getPolicyId(); void setPolicyId(String policyId); Map<String, Object> getAlertData(); void setAlertData(Map<String, Object> alertData); static AlertPublishEvent createAlertPublishEvent(AlertStreamEvent event); String toString(); String getAlertSubject(); void setAlertSubject(String alertSubject); String getAlertBody(); void setAlertBody(String alertBody); String getStreamId(); void setStreamId(String streamId); String getCreatedBy(); void setCreatedBy(String createdBy); long getCreatedTime(); void setCreatedTime(long createdTime); static final String ALERT_ID_KEY; static final String SITE_ID_KEY; static final String APP_IDS_KEY; static final String POLICY_ID_KEY; static final String POLICY_VALUE_KEY; static final String ALERT_CATEGORY; static final String ALERT_SEVERITY; static final String ALERT_HOST; }
@Test public void testAlertPublishEvent() { thrown.expect(NullPointerException.class); AlertStreamEvent alertStreamEvent = new AlertStreamEvent(); AlertPublishEvent.createAlertPublishEvent(alertStreamEvent); }
@Test public void testAlertPublishEvent1() { thrown.expect(NullPointerException.class); List<StreamColumn> streamColumns = new ArrayList<>(); streamColumns.add(new StreamColumn.Builder().name("name").type(StreamColumn.Type.STRING).build()); streamColumns.add(new StreamColumn.Builder().name("host").type(StreamColumn.Type.STRING).build()); streamColumns.add(new StreamColumn.Builder().name("flag").type(StreamColumn.Type.BOOL).build()); streamColumns.add(new StreamColumn.Builder().name("value").type(StreamColumn.Type.DOUBLE).build()); streamColumns.add(new StreamColumn.Builder().name("data").type(StreamColumn.Type.LONG).build()); streamColumns.add(new StreamColumn.Builder().name("salary").type(StreamColumn.Type.FLOAT).build()); streamColumns.add(new StreamColumn.Builder().name("object").type(StreamColumn.Type.OBJECT).build()); streamColumns.add(new StreamColumn.Builder().name("int").type(StreamColumn.Type.INT).build()); StreamDefinition streamDefinition = new StreamDefinition(); streamDefinition.setColumns(streamColumns); AlertStreamEvent alertStreamEvent = new AlertStreamEvent(); alertStreamEvent.setSchema(streamDefinition); AlertPublishEvent.createAlertPublishEvent(alertStreamEvent); }