@Test public void _01_publish() throws Exception { final AlarmInputMessage message = new AlarmInputMessage(ALERT_NAME, "Level theshold reached"); platformTemplate.getAlarmOps().publish(message); assertTrue("Wrong call to Sentilo", true); }
@Test public void _02_publishWithoutAlarmMessage() throws Exception { final AlarmInputMessage message = new AlarmInputMessage("mockTestAlert"); boolean error = false; try { platformTemplate.getAlarmOps().publish(message); } catch (final PlatformClientAccessException e) { error = true; } assertTrue("Wrong call to Sentilo", error); }
public void publishAlarm(final InternalAlert alert, final String message) { LOGGER.debug("Publishing new alarm, related to (alert, sensor, provider) ({}, {} , {}), with message: {} ", alert.getId(), alert.getSensorId(), alert.getProviderId(), message); // Publish directly via API REST final AlarmInputMessage alarmMessage = new AlarmInputMessage(alert.getId(), message); alarmMessage.setProviderId(alert.getProviderId()); alarmMessage.setSensorId(alert.getSensorId()); alarmMessage.setAlertType(alert.getTrigger().name()); platformClient.getAlarmOps().publish(alarmMessage); } }