Search in sources :

Example 6 with PatternTemplate

use of com.epam.ta.reportportal.entity.pattern.PatternTemplate in project service-api by reportportal.

the class PatternTemplateBuilderTest method patternTemplateBuilder.

@Test
void patternTemplateBuilder() {
    CreatePatternTemplateRQ createPatternTemplateRQ = new CreatePatternTemplateRQ();
    String name = "name";
    String type = "STRING";
    boolean enabled = true;
    String value = "qwe";
    createPatternTemplateRQ.setName(name);
    createPatternTemplateRQ.setType(type);
    createPatternTemplateRQ.setEnabled(enabled);
    createPatternTemplateRQ.setValue(value);
    PatternTemplate patternTemplate = new PatternTemplateBuilder().withCreateRequest(createPatternTemplateRQ).get();
    assertEquals(name, patternTemplate.getName());
    assertEquals(type, patternTemplate.getTemplateType().name());
    assertEquals(enabled, patternTemplate.isEnabled());
    assertEquals(value, patternTemplate.getValue());
}
Also used : CreatePatternTemplateRQ(com.epam.ta.reportportal.ws.model.project.config.pattern.CreatePatternTemplateRQ) PatternTemplate(com.epam.ta.reportportal.entity.pattern.PatternTemplate) Test(org.junit.jupiter.api.Test)

Example 7 with PatternTemplate

use of com.epam.ta.reportportal.entity.pattern.PatternTemplate 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)

Example 8 with PatternTemplate

use of com.epam.ta.reportportal.entity.pattern.PatternTemplate in project service-api by reportportal.

the class PatternAnalyzerTest method getPatternTemplate.

private PatternTemplate getPatternTemplate(Long id, String name, String value, PatternTemplateType type) {
    PatternTemplate patternTemplate = new PatternTemplate();
    patternTemplate.setId(id);
    patternTemplate.setName(name);
    patternTemplate.setValue(value);
    patternTemplate.setEnabled(true);
    patternTemplate.setTemplateType(type);
    patternTemplate.setProjectId(1L);
    return patternTemplate;
}
Also used : PatternTemplate(com.epam.ta.reportportal.entity.pattern.PatternTemplate)

Example 9 with PatternTemplate

use of com.epam.ta.reportportal.entity.pattern.PatternTemplate in project service-api by reportportal.

the class CreatePatternTemplateHandlerImpl method createPatternTemplate.

@Override
public PatternTemplate createPatternTemplate(Long projectId, CreatePatternTemplateRQ createPatternTemplateRQ) {
    final String name = StringUtils.trim(createPatternTemplateRQ.getName());
    BusinessRule.expect(patternTemplateRepository.existsByProjectIdAndNameIgnoreCase(projectId, name), equalTo(false)).verify(ErrorType.RESOURCE_ALREADY_EXISTS, name);
    PatternTemplate patternTemplate = new PatternTemplateBuilder().withCreateRequest(createPatternTemplateRQ).withName(name).withProjectId(projectId).get();
    return patternTemplateRepository.save(patternTemplate);
}
Also used : PatternTemplate(com.epam.ta.reportportal.entity.pattern.PatternTemplate) PatternTemplateBuilder(com.epam.ta.reportportal.ws.converter.builders.PatternTemplateBuilder)

Aggregations

PatternTemplate (com.epam.ta.reportportal.entity.pattern.PatternTemplate)9 Project (com.epam.ta.reportportal.entity.project.Project)3 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)3 PatternTemplateActivityResource (com.epam.ta.reportportal.ws.model.activity.PatternTemplateActivityResource)3 Test (org.junit.jupiter.api.Test)3 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)2 PatternCreatedEvent (com.epam.ta.reportportal.core.events.activity.PatternCreatedEvent)1 PatternDeletedEvent (com.epam.ta.reportportal.core.events.activity.PatternDeletedEvent)1 PatternUpdatedEvent (com.epam.ta.reportportal.core.events.activity.PatternUpdatedEvent)1 PatternTemplateBuilder (com.epam.ta.reportportal.ws.converter.builders.PatternTemplateBuilder)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1 CreatePatternTemplateRQ (com.epam.ta.reportportal.ws.model.project.config.pattern.CreatePatternTemplateRQ)1 PatternTemplateResource (com.epam.ta.reportportal.ws.model.project.config.pattern.PatternTemplateResource)1