AsyncEmailSender extends AbstractSender { @VisibleForTesting @SuppressWarnings("unchecked") protected EventModel createEventModel(AlertMessageEntity message, EmailResponse response) { EventModel model = new EventModel(); model.setEventType(EventModel.EventType.ALERT_EMAIL).setEventOperator(FoundationService.DEFAULT.getLocalIp()) .setEventDetail(message.getTitle()); if(message.getAlert() != null) { model.setEventOperation(message.getAlert().getAlertType().name()); } else { model.setEventOperation("grouped"); } String emailCheckInfo = null; try { emailCheckInfo = JsonCodec.INSTANCE.encode(response.getProperties()); } catch (Exception e) { logger.error("[createEventModel] Error encode check info"); } model.setEventProperty(emailCheckInfo); return model; }  @Override String getId(); @PostConstruct void initListeners(); @Override boolean send(AlertMessageEntity message); @VisibleForTesting AsyncEmailSenderCallback getCallbackFunction(); static final String ID; }
@Test public void testCreateEventModel() { AlertMessageEntity message = new AlertMessageEntity("Test", "test", Lists.newArrayList("test-list")); message.setAlert(new AlertEntity(new HostPort("192.168.0.1", 1234), dcNames[0], "clusterId", "shardId", "message", ALERT_TYPE.CLIENT_INSTANCE_NOT_OK)); }