@Test public void testDeleteTimeAlert() { Long clusterId = 10L; Long alertId = 20L; when(timeAlertRepository.findByCluster(alertId, clusterId)).thenReturn(mockTimeAlert); when(clusterService.findById(clusterId)).thenReturn(mockCluster); underTest.deleteTimeAlert(clusterId, alertId); verify(mockCluster).setTimeAlerts(any(Set.class)); verify(timeAlertRepository).delete(mockTimeAlert); verify(clusterService).save(mockCluster); }
public void deleteTimeAlert(Long clusterId, Long alertId) { Cluster cluster = clusterService.findById(clusterId); TimeAlert timeAlert = timeAlertRepository.findByCluster(alertId, clusterId); cluster.setTimeAlerts(removeTimeAlert(cluster, alertId)); timeAlertRepository.delete(timeAlert); clusterService.save(cluster); }
AlertService { public void deleteTimeAlert(Long clusterId, Long alertId) { Cluster cluster = clusterService.findById(clusterId); TimeAlert timeAlert = timeAlertRepository.findByCluster(alertId, clusterId); cluster.setTimeAlerts(removeTimeAlert(cluster, alertId)); timeAlertRepository.delete(timeAlert); clusterService.save(cluster); } }
AlertService { public void deleteTimeAlert(Long clusterId, Long alertId) { Cluster cluster = clusterService.findById(clusterId); TimeAlert timeAlert = timeAlertRepository.findByCluster(alertId, clusterId); cluster.setTimeAlerts(removeTimeAlert(cluster, alertId)); timeAlertRepository.delete(timeAlert); clusterService.save(cluster); }  }
AlertService { public void deleteTimeAlert(Long clusterId, Long alertId) { Cluster cluster = clusterService.findById(clusterId); TimeAlert timeAlert = timeAlertRepository.findByCluster(alertId, clusterId); cluster.setTimeAlerts(removeTimeAlert(cluster, alertId)); timeAlertRepository.delete(timeAlert); clusterService.save(cluster); }  TimeAlert createTimeAlert(Long clusterId, TimeAlert alert); TimeAlert findTimeAlertByCluster(Long clusterId, Long alertId); TimeAlert updateTimeAlert(Long clusterId, Long alertId, TimeAlert timeAlertForUpdate); Set<TimeAlert> getTimeAlerts(Long clusterId); void deleteTimeAlert(Long clusterId, Long alertId); Set<TimeAlert> removeTimeAlert(Cluster cluster, Long alertId); BaseAlert getBaseAlert(Long clusterId, Long alertId); BaseAlert save(BaseAlert alert); LoadAlert createLoadAlert(Long clusterId, LoadAlert loadAlert); LoadAlert updateLoadAlert(Long clusterId, Long alertId, LoadAlert loadAlertForUpdate); LoadAlert findLoadAlertByCluster(Long clusterId, Long alertId); void deleteLoadAlert(Long clusterId, Long alertId); Set<LoadAlert> removeLoadAlert(Cluster cluster, Long alertId); Set<LoadAlert> getLoadAlertsForClusterHostGroup(Long clusterId, String hostGroup); Set<LoadAlert> getLoadAlerts(Long clusterId); }
AlertService { public void deleteTimeAlert(Long clusterId, Long alertId) { Cluster cluster = clusterService.findById(clusterId); TimeAlert timeAlert = timeAlertRepository.findByCluster(alertId, clusterId); cluster.setTimeAlerts(removeTimeAlert(cluster, alertId)); timeAlertRepository.delete(timeAlert); clusterService.save(cluster); }  TimeAlert createTimeAlert(Long clusterId, TimeAlert alert); TimeAlert findTimeAlertByCluster(Long clusterId, Long alertId); TimeAlert updateTimeAlert(Long clusterId, Long alertId, TimeAlert timeAlertForUpdate); Set<TimeAlert> getTimeAlerts(Long clusterId); void deleteTimeAlert(Long clusterId, Long alertId); Set<TimeAlert> removeTimeAlert(Cluster cluster, Long alertId); BaseAlert getBaseAlert(Long clusterId, Long alertId); BaseAlert save(BaseAlert alert); LoadAlert createLoadAlert(Long clusterId, LoadAlert loadAlert); LoadAlert updateLoadAlert(Long clusterId, Long alertId, LoadAlert loadAlertForUpdate); LoadAlert findLoadAlertByCluster(Long clusterId, Long alertId); void deleteLoadAlert(Long clusterId, Long alertId); Set<LoadAlert> removeLoadAlert(Cluster cluster, Long alertId); Set<LoadAlert> getLoadAlertsForClusterHostGroup(Long clusterId, String hostGroup); Set<LoadAlert> getLoadAlerts(Long clusterId);  }