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());
}
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());
}
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;
}
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);
}
Aggregations