@Test public void executeEmailServiceForAssetGroupTest(){ List<Map<String, Object>> ownerEmailDetails=new ArrayList<Map<String,Object>>(); Map<String,Object>ownerDetails=new HashMap<>(); ownerDetails.put("ownerName", "jack"); ownerDetails.put("assetGroup", "aws-all"); ownerDetails.put("ownerEmail", "test@mail.com"); ownerDetails.put("ownerName", "jack"); ownerEmailDetails.add(ownerDetails); Map<String,Object>patchingDetails=new HashMap<>(); patchingDetails.put("unpatched_instances", 0); patchingDetails.put("patched_instances", 5816); patchingDetails.put("total_instances", 5816); patchingDetails.put("patching_percentage", 100); Response patchingResponse = new Response(); patchingResponse.setData(patchingDetails); Map<String,Object>certificateDetails=new HashMap<>(); certificateDetails.put("certificates", 1284); certificateDetails.put("certificates_expiring", 0); Response CertificateResponse = new Response(); CertificateResponse.setData(certificateDetails); Map<String,Object> taggingDetails=new HashMap<>(); taggingDetails.put("assets", 122083); taggingDetails.put("untagged", 47744); taggingDetails.put("tagged", 74339); taggingDetails.put("compliance", 60); Response taggingResponse = new Response(); taggingResponse.setData(taggingDetails); Map<String,Object> vulnerabilityDetails=new HashMap<>(); vulnerabilityDetails.put("hosts", 6964); vulnerabilityDetails.put("vulnerabilities", 94258); vulnerabilityDetails.put("totalVulnerableAssets", 5961); Response vulnerabilityResponse = new Response(); vulnerabilityResponse.setData(taggingDetails); Map<String,Object> complianceStats=new HashMap<>(); complianceStats.put("hosts", 6964); complianceStats.put("vulnerabilities", 94258); complianceStats.put("totalVulnerableAssets", 5961); Response complianceStatsResponse = new Response(); complianceStatsResponse.setData(complianceStats); Map<String,Object> topNonCompliant = new HashMap<>(); topNonCompliant.put("hosts", 6964); topNonCompliant.put("vulnerabilities", 94258); topNonCompliant.put("totalVulnerableAssets", 5961); Response topNonCompliantAppsResponse = new Response(); topNonCompliantAppsResponse.setData(topNonCompliant); Map<String, Object> responseDetails = Maps.newHashMap(); responseDetails.put("application", "application123"); List<Map<String, Object>> response = Lists.newArrayList(); response.add(responseDetails); Map<String,Object> applicationNames = new HashMap<>(); applicationNames.put("response", response); applicationNames.put("vulnerabilities", 94258); applicationNames.put("totalVulnerableAssets", 5961); Response applicationNamesResponse = new Response(); applicationNamesResponse.setData(applicationNames); Map<String,Object> issueDetails = new HashMap<>(); issueDetails.put("hosts", 6964); issueDetails.put("vulnerabilities", 94258); issueDetails.put("totalVulnerableAssets", 5961); Response issueDetailsResponse = new Response(); issueDetailsResponse.setData(issueDetails); issueDetailsResponse.setMessage("message"); assertTrue(issueDetailsResponse.getMessage().equals("message")); ReflectionTestUtils.setField(assetGroupEmailService, "mailTemplateUrl", mailTemplateUrl); when(complianceServiceClient.getPatching(anyString())).thenReturn(patchingResponse); when(complianceServiceClient.getCertificates(anyString())).thenReturn(CertificateResponse); when(complianceServiceClient.getTagging(anyString())).thenReturn(taggingResponse); when(statisticsServiceClient.getComplianceStats(anyString())).thenReturn(complianceStatsResponse); when(complianceServiceClient.getVulnerabilities(anyString())).thenReturn(vulnerabilityResponse); when(complianceServiceClient.getTopNonCompliantApps(anyString())).thenReturn(topNonCompliantAppsResponse); when(complianceServiceClient.getVulnerabilityByApplications(anyString())).thenReturn(applicationNamesResponse); when(complianceServiceClient.getDistribution(anyString())).thenReturn(issueDetailsResponse); when(notificationService.getAllAssetGroupOwnerEmailDetails()).thenReturn(ownerEmailDetails); assetGroupEmailService.executeEmailServiceForAssetGroup(); }
public void executeEmailServiceForAssetGroup() { log.info(EMAIL_SERVICE_STARTED); List<Map<String, Object>> ownerEmailDetails = notificationService.getAllAssetGroupOwnerEmailDetails(); ExecutorService emailExecutor = Executors.newSingleThreadExecutor(); String domainUrl = System.getenv("DOMAIN_URL"); for(Map<String, Object> ownerEmailDetail : ownerEmailDetails) { emailExecutor.execute(new Runnable() { @Override public void run() { String ownnerName = ownerEmailDetail.get("ownerName").toString(); String assetGroupName = ownerEmailDetail.get("assetGroup").toString(); String ownerEmail = ownerEmailDetail.get("ownerEmail").toString(); sendDigestMail(assetGroupName, ownnerName, ownerEmail, mailTemplateUrl, domainUrl); } }); } emailExecutor.shutdown(); log.info(EMAIL_SERVICE_COMPLETED); }
AssetGroupEmailService implements Constants { public void executeEmailServiceForAssetGroup() { log.info(EMAIL_SERVICE_STARTED); List<Map<String, Object>> ownerEmailDetails = notificationService.getAllAssetGroupOwnerEmailDetails(); ExecutorService emailExecutor = Executors.newSingleThreadExecutor(); String domainUrl = System.getenv("DOMAIN_URL"); for(Map<String, Object> ownerEmailDetail : ownerEmailDetails) { emailExecutor.execute(new Runnable() { @Override public void run() { String ownnerName = ownerEmailDetail.get("ownerName").toString(); String assetGroupName = ownerEmailDetail.get("assetGroup").toString(); String ownerEmail = ownerEmailDetail.get("ownerEmail").toString(); sendDigestMail(assetGroupName, ownnerName, ownerEmail, mailTemplateUrl, domainUrl); } }); } emailExecutor.shutdown(); log.info(EMAIL_SERVICE_COMPLETED); } }
AssetGroupEmailService implements Constants { public void executeEmailServiceForAssetGroup() { log.info(EMAIL_SERVICE_STARTED); List<Map<String, Object>> ownerEmailDetails = notificationService.getAllAssetGroupOwnerEmailDetails(); ExecutorService emailExecutor = Executors.newSingleThreadExecutor(); String domainUrl = System.getenv("DOMAIN_URL"); for(Map<String, Object> ownerEmailDetail : ownerEmailDetails) { emailExecutor.execute(new Runnable() { @Override public void run() { String ownnerName = ownerEmailDetail.get("ownerName").toString(); String assetGroupName = ownerEmailDetail.get("assetGroup").toString(); String ownerEmail = ownerEmailDetail.get("ownerEmail").toString(); sendDigestMail(assetGroupName, ownnerName, ownerEmail, mailTemplateUrl, domainUrl); } }); } emailExecutor.shutdown(); log.info(EMAIL_SERVICE_COMPLETED); }  }
AssetGroupEmailService implements Constants { public void executeEmailServiceForAssetGroup() { log.info(EMAIL_SERVICE_STARTED); List<Map<String, Object>> ownerEmailDetails = notificationService.getAllAssetGroupOwnerEmailDetails(); ExecutorService emailExecutor = Executors.newSingleThreadExecutor(); String domainUrl = System.getenv("DOMAIN_URL"); for(Map<String, Object> ownerEmailDetail : ownerEmailDetails) { emailExecutor.execute(new Runnable() { @Override public void run() { String ownnerName = ownerEmailDetail.get("ownerName").toString(); String assetGroupName = ownerEmailDetail.get("assetGroup").toString(); String ownerEmail = ownerEmailDetail.get("ownerEmail").toString(); sendDigestMail(assetGroupName, ownnerName, ownerEmail, mailTemplateUrl, domainUrl); } }); } emailExecutor.shutdown(); log.info(EMAIL_SERVICE_COMPLETED); }  void executeEmailServiceForAssetGroup(); @SuppressWarnings("unchecked") void sendDigestMail(String assetGroupName, String ownerName, String ownerEmail, String mainTemplateUrl, String domainUrl); }
AssetGroupEmailService implements Constants { public void executeEmailServiceForAssetGroup() { log.info(EMAIL_SERVICE_STARTED); List<Map<String, Object>> ownerEmailDetails = notificationService.getAllAssetGroupOwnerEmailDetails(); ExecutorService emailExecutor = Executors.newSingleThreadExecutor(); String domainUrl = System.getenv("DOMAIN_URL"); for(Map<String, Object> ownerEmailDetail : ownerEmailDetails) { emailExecutor.execute(new Runnable() { @Override public void run() { String ownnerName = ownerEmailDetail.get("ownerName").toString(); String assetGroupName = ownerEmailDetail.get("assetGroup").toString(); String ownerEmail = ownerEmailDetail.get("ownerEmail").toString(); sendDigestMail(assetGroupName, ownnerName, ownerEmail, mailTemplateUrl, domainUrl); } }); } emailExecutor.shutdown(); log.info(EMAIL_SERVICE_COMPLETED); }  void executeEmailServiceForAssetGroup(); @SuppressWarnings("unchecked") void sendDigestMail(String assetGroupName, String ownerName, String ownerEmail, String mainTemplateUrl, String domainUrl);  }