@Test public void testCreateTimeAlert() { Long clusterId = 10L; TimeAlert testAlert = getTimeAlert(); when(clusterService.findById(clusterId)).thenReturn(mockCluster); when(clusterService.save(mockCluster)).thenReturn(mockCluster); when(timeAlertRepository.save(testAlert)).thenReturn(mockTimeAlert); TimeAlert response = underTest.createTimeAlert(clusterId, testAlert); assertNotNull("TestAlert should not be null", response); assertNotNull("TestAlert' cluster should not be null", testAlert.getCluster()); verify(timeAlertRepository).save(any(TimeAlert.class)); verify(clusterService).findById(clusterId); verify(clusterService).save(mockCluster); verify(mockCluster).addTimeAlert(mockTimeAlert); }
public TimeAlert createTimeAlert(Long clusterId, TimeAlert alert) { Cluster cluster = clusterService.findById(clusterId); alert.setCluster(cluster); alert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); alert = (TimeAlert) save(alert); cluster.addTimeAlert(alert); clusterService.save(cluster); return alert; }
AlertService { public TimeAlert createTimeAlert(Long clusterId, TimeAlert alert) { Cluster cluster = clusterService.findById(clusterId); alert.setCluster(cluster); alert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); alert = (TimeAlert) save(alert); cluster.addTimeAlert(alert); clusterService.save(cluster); return alert; } }
AlertService { public TimeAlert createTimeAlert(Long clusterId, TimeAlert alert) { Cluster cluster = clusterService.findById(clusterId); alert.setCluster(cluster); alert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); alert = (TimeAlert) save(alert); cluster.addTimeAlert(alert); clusterService.save(cluster); return alert; }  }
AlertService { public TimeAlert createTimeAlert(Long clusterId, TimeAlert alert) { Cluster cluster = clusterService.findById(clusterId); alert.setCluster(cluster); alert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); alert = (TimeAlert) save(alert); cluster.addTimeAlert(alert); clusterService.save(cluster); return alert; }  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 TimeAlert createTimeAlert(Long clusterId, TimeAlert alert) { Cluster cluster = clusterService.findById(clusterId); alert.setCluster(cluster); alert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); alert = (TimeAlert) save(alert); cluster.addTimeAlert(alert); clusterService.save(cluster); return alert; }  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);  }