@Test public void testCreateLoadAlert() { Long clusterId = 10L; LoadAlert testAlert = getLoadAlert(); when(clusterService.findById(clusterId)).thenReturn(mockCluster); when(clusterService.save(mockCluster)).thenReturn(mockCluster); when(loadAlertRepository.save(testAlert)).thenReturn(mockLoadAlert); LoadAlert response = underTest.createLoadAlert(clusterId, testAlert); assertNotNull("LoadAlert should not be null", response); assertNotNull("LoadAlert' cluster should not be null", testAlert.getCluster()); verify(loadAlertRepository).save(any(LoadAlert.class)); verify(clusterService).findById(clusterId); verify(clusterService).save(mockCluster); }
public LoadAlert createLoadAlert(Long clusterId, LoadAlert loadAlert) { Cluster cluster = clusterService.findById(clusterId); loadAlert.setCluster(cluster); loadAlert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); loadAlert = (LoadAlert) save(loadAlert); cluster.addLoadAlert(loadAlert); clusterService.save(cluster); return loadAlert; }
AlertService { public LoadAlert createLoadAlert(Long clusterId, LoadAlert loadAlert) { Cluster cluster = clusterService.findById(clusterId); loadAlert.setCluster(cluster); loadAlert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); loadAlert = (LoadAlert) save(loadAlert); cluster.addLoadAlert(loadAlert); clusterService.save(cluster); return loadAlert; } }
AlertService { public LoadAlert createLoadAlert(Long clusterId, LoadAlert loadAlert) { Cluster cluster = clusterService.findById(clusterId); loadAlert.setCluster(cluster); loadAlert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); loadAlert = (LoadAlert) save(loadAlert); cluster.addLoadAlert(loadAlert); clusterService.save(cluster); return loadAlert; }  }
AlertService { public LoadAlert createLoadAlert(Long clusterId, LoadAlert loadAlert) { Cluster cluster = clusterService.findById(clusterId); loadAlert.setCluster(cluster); loadAlert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); loadAlert = (LoadAlert) save(loadAlert); cluster.addLoadAlert(loadAlert); clusterService.save(cluster); return loadAlert; }  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 LoadAlert createLoadAlert(Long clusterId, LoadAlert loadAlert) { Cluster cluster = clusterService.findById(clusterId); loadAlert.setCluster(cluster); loadAlert.setAlertCrn(createAlertCrn(ThreadBasedUserCrnProvider.getAccountId())); loadAlert = (LoadAlert) save(loadAlert); cluster.addLoadAlert(loadAlert); clusterService.save(cluster); return loadAlert; }  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);  }