use of com.sequenceiq.cloudbreak.service.notification.Notification in project cloudbreak by hortonworks.
the class UptimeNotifierTest method notificationSendingWhenCredentialNullEverythingWorkFine.
@Test
public void notificationSendingWhenCredentialNullEverythingWorkFine() {
doNothing().when(notificationSender).send(any(Notification.class));
List<Cluster> clusters = TestUtil.generateCluster(1);
when(clusterRepository.findByStatuses(any())).thenReturn(Collections.singletonList(clusters.get(0)));
Stack stack2 = TestUtil.stack();
stack2.setCluster(clusters.get(0));
stack2.setCredential(null);
when(stackRepository.findStackForCluster(anyLong())).thenReturn(stack2);
underTest.sendUptime();
ArgumentCaptor<Notification> argument2 = ArgumentCaptor.forClass(Notification.class);
verify(notificationSender).send(argument2.capture());
Notification<CloudbreakEventsJson> notification = argument2.getValue();
assertEquals("null", notification.getNotification().getCloud());
assertEquals("multi-node-yarn", notification.getNotification().getBlueprintName());
assertEquals(Long.valueOf(1), notification.getNotification().getBlueprintId());
verify(notificationSender, times(1)).send(any(Notification.class));
}
use of com.sequenceiq.cloudbreak.service.notification.Notification in project cloudbreak by hortonworks.
the class UptimeNotifier method createUptimeNotification.
private Notification<CloudbreakEventsJson> createUptimeNotification(Stack stack, Long uptime) {
CloudbreakEventsJson notification = new CloudbreakEventsJson();
notification.setOwner(stack.getOwner());
notification.setAccount(stack.getAccount());
notification.setStackId(stack.getId());
notification.setEventType(UPTIME_NOTIFICATION);
notification.setEventMessage(String.valueOf(uptime));
if (stack.getCredential() == null) {
notification.setCloud("null");
} else {
notification.setCloud(stack.getCredential().cloudPlatform());
}
if (stack.getCluster() == null || stack.getCluster().getBlueprint() == null) {
notification.setBlueprintId(null);
notification.setBlueprintName("null");
} else {
notification.setBlueprintId(stack.getCluster().getBlueprint().getId());
notification.setBlueprintName(stack.getCluster().getBlueprint().getAmbariName());
notification.setClusterName(stack.getCluster().getName());
notification.setClusterId(stack.getCluster().getId());
}
return new Notification<>(notification);
}
Aggregations