use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel in project hub-alert by blackducksoftware.
the class AuditEntryHandlerTestIT method getGetAuditInfoForJobIT.
@Test
public void getGetAuditInfoForJobIT() {
DistributionJobRequestModel jobRequestModel = createJobRequestModel();
DistributionJobModel job = jobAccessor.createJob(jobRequestModel);
AuditEntryEntity savedAuditEntryEntity = auditEntryRepository.save(new AuditEntryEntity(job.getJobId(), DateUtils.createCurrentDateTimestamp(), DateUtils.createCurrentDateTimestamp(), AuditEntryStatus.SUCCESS.toString(), null, null));
AuthorizationManager authorizationManager = Mockito.mock(AuthorizationManager.class);
Mockito.when(authorizationManager.hasReadPermission(Mockito.eq(ConfigContextEnum.GLOBAL), Mockito.eq(auditDescriptorKey))).thenReturn(true);
AuditEntryActions auditEntryController = createAuditActions(authorizationManager);
AuditJobStatusModel jobStatusModel = auditEntryController.getAuditInfoForJob(savedAuditEntryEntity.getCommonConfigId()).getContent().orElse(null);
assertNotNull(jobStatusModel);
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel in project hub-alert by blackducksoftware.
the class PhoneHomeTask method retrieveChannelMetadataForJobs.
private Set<String> retrieveChannelMetadataForJobs(List<DistributionJobModel> jobs) {
Map<String, Integer> createdDistributions = new HashMap<>();
for (DistributionJobModel job : jobs) {
String channelName = job.getChannelDescriptorName();
String providerName = providerKey.getUniversalKey();
updateMetaDataCount(createdDistributions, channelName);
updateMetaDataCount(createdDistributions, providerName);
if (hasAuditSuccess(job.getJobId())) {
updateMetaDataCount(createdDistributions, channelName + SUCCESS_KEY_PART);
updateMetaDataCount(createdDistributions, providerName + SUCCESS_KEY_PART);
}
}
return createdDistributions.entrySet().stream().map(entry -> entry.getKey() + "(" + entry.getValue() + ")").collect(Collectors.toSet());
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel in project hub-alert by blackducksoftware.
the class EmailTestActionHelperTest method verifyProjectsRetrievedWithOnlyVersionPattern.
@Test
public void verifyProjectsRetrievedWithOnlyVersionPattern() throws AlertException {
ProviderDataAccessor providerDataAccessor = Mockito.mock(ProviderDataAccessor.class);
List<ProviderProject> providerProjects = createProviderProjects();
Mockito.when(providerDataAccessor.getProjectsByProviderConfigId(Mockito.anyLong())).thenReturn(providerProjects);
Mockito.when(providerDataAccessor.getEmailAddressesForProjectHref(Mockito.anyLong(), Mockito.anyString())).thenAnswer(i -> Set.of(UUID.randomUUID().toString()));
Mockito.when(providerDataAccessor.getProjectVersionNamesByHref(Mockito.anyLong(), Mockito.anyString(), Mockito.anyInt())).thenReturn(getProjectVersions());
EmailTestActionHelper emailTestActionHelper = new EmailTestActionHelper(providerDataAccessor);
DistributionJobModel distributionJobModel = createDistributionJobModel(createDefaultEmailJobDetails(), null, "1.0.*", List.of());
Set<String> emailAddresses = emailTestActionHelper.createUpdatedEmailAddresses(distributionJobModel);
assertEquals(providerProjects.size(), emailAddresses.size());
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel in project hub-alert by blackducksoftware.
the class JobConfigActions method findJobFieldModel.
@Override
protected Optional<JobFieldModel> findJobFieldModel(UUID id) {
Optional<DistributionJobModel> optionalJob = jobAccessor.getJobById(id);
if (optionalJob.isPresent()) {
DistributionJobModel distributionJobModel = optionalJob.get();
List<JobProviderProjectFieldModel> jobProviderProjects = JobFieldModelPopulationUtils.createJobProviderProjects(distributionJobModel);
providerProjectExistencePopulator.populateJobProviderProjects(distributionJobModel.getBlackDuckGlobalConfigId(), jobProviderProjects);
JobFieldModel jobFieldModel = JobFieldModelPopulationUtils.createJobFieldModel(distributionJobModel, jobProviderProjects);
return Optional.of(jobFieldModel);
}
return Optional.empty();
}
use of com.synopsys.integration.alert.common.persistence.model.job.DistributionJobModel in project hub-alert by blackducksoftware.
the class JobConfigActions method createWithoutChecks.
@Override
protected ActionResponse<JobFieldModel> createWithoutChecks(JobFieldModel resource) {
try {
Set<ConfigurationFieldModel> configurationFieldModels = new HashSet<>();
for (FieldModel fieldModel : resource.getFieldModels()) {
FieldModel beforeSaveEventFieldModel = fieldModelProcessor.performBeforeSaveAction(fieldModel);
Collection<ConfigurationFieldModel> savedFieldsModels = modelConverter.convertToConfigurationFieldModelMap(beforeSaveEventFieldModel).values();
configurationFieldModels.addAll(savedFieldsModels);
}
List<JobProviderProjectFieldModel> configuredProviderProjects = Optional.ofNullable(resource.getConfiguredProviderProjects()).orElse(List.of());
DistributionJobRequestModel jobRequestModel = createDistributionJobRequestModel(configurationFieldModels, configuredProviderProjects, DateUtils.createCurrentDateTimestamp(), null);
DistributionJobModel savedJob = jobAccessor.createJob(jobRequestModel);
JobFieldModel savedJobFieldModel = JobFieldModelPopulationUtils.createJobFieldModel(savedJob, configuredProviderProjects);
Set<FieldModel> updatedFieldModels = new HashSet<>();
for (FieldModel fieldModel : savedJobFieldModel.getFieldModels()) {
FieldModel updatedModel = fieldModelProcessor.performAfterSaveAction(fieldModel);
updatedFieldModels.add(updatedModel);
}
savedJobFieldModel.setFieldModels(updatedFieldModels);
return new ActionResponse<>(HttpStatus.OK, savedJobFieldModel);
} catch (AlertException ex) {
logger.error("Error creating job", ex);
return new ActionResponse<>(HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
}
}
Aggregations