Search in sources :

Example 1 with PatternCreatedEvent

use of com.epam.ta.reportportal.core.events.activity.PatternCreatedEvent in project service-api by reportportal.

the class CreateProjectSettingsHandlerImpl method createPatternTemplate.

@Override
public EntryCreatedRS createPatternTemplate(String projectName, CreatePatternTemplateRQ createPatternTemplateRQ, ReportPortalUser user) {
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectName));
    PatternTemplate patternTemplate = createPatternTemplateMapping.get(PatternTemplateType.fromString(createPatternTemplateRQ.getType()).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, Suppliers.formattedSupplier("Unknown pattern template type - '{}'", createPatternTemplateRQ.getType()).get()))).createPatternTemplate(project.getId(), createPatternTemplateRQ);
    messageBus.publishActivity(new PatternCreatedEvent(user.getUserId(), user.getUsername(), PatternTemplateConverter.TO_ACTIVITY_RESOURCE.apply(patternTemplate)));
    return new EntryCreatedRS(patternTemplate.getId());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) PatternCreatedEvent(com.epam.ta.reportportal.core.events.activity.PatternCreatedEvent) EntryCreatedRS(com.epam.ta.reportportal.ws.model.EntryCreatedRS) PatternTemplate(com.epam.ta.reportportal.entity.pattern.PatternTemplate)

Aggregations

PatternCreatedEvent (com.epam.ta.reportportal.core.events.activity.PatternCreatedEvent)1 PatternTemplate (com.epam.ta.reportportal.entity.pattern.PatternTemplate)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1