Search in sources :

Example 1 with LoggingContext

use of com.epam.reportportal.service.LoggingContext in project agent-java-soapui by reportportal.

the class CustomLoggerService method log.

public static void log(String message, String level) {
    if (TEST_CASE_ID != null) {
        LoggingContext loggingContext = CONTEXT_MAP.get(TEST_CASE_ID);
        loggingContext.emit(asFunction(message, level, Calendar.getInstance().getTime()));
    }
}
Also used : LoggingContext(com.epam.reportportal.service.LoggingContext)

Example 2 with LoggingContext

use of com.epam.reportportal.service.LoggingContext in project agent-java-soapui by reportportal.

the class TestBasedSoapUIServiceImpl method startTestStep.

public void startTestStep(TestStep testStep, TestCaseRunContext context) {
    if (!RpServiceBuilder.REPORTER_DISABLE) {
        String log = asMarkdown(String.format("# ===========STEP '%s' STARTED===========", testStep.getName()));
        LoggingContext loggingContext = CONTEXT_MAP.get(TEST_CASE_ID);
        loggingContext.emit(asFunction(log, LEVEL_INFO, Calendar.getInstance().getTime()));
    }
}
Also used : LoggingContext(com.epam.reportportal.service.LoggingContext)

Example 3 with LoggingContext

use of com.epam.reportportal.service.LoggingContext in project agent-java-soapui by reportportal.

the class TestBasedSoapUIServiceImpl method finishTestStep.

public void finishTestStep(TestStepResult testStepContext, TestCaseRunContext paramTestCaseRunContext) {
    LoggingContext loggingContext = CONTEXT_MAP.get(TEST_CASE_ID);
    if (!RpServiceBuilder.REPORTER_DISABLE) {
        String logStepData = getLogStepData(testStepContext);
        if (!Strings.isNullOrEmpty(logStepData)) {
            loggingContext.emit(asFunction(logStepData, LEVEL_INFO, Calendar.getInstance().getTime()));
        }
        for (final SaveLogRQ rq : getStepLogReport(testStepContext)) {
            loggingContext.emit(new Function<String, SaveLogRQ>() {

                @Override
                public SaveLogRQ apply(String id) {
                    rq.setTestItemId(id);
                    return rq;
                }
            });
        }
    }
    if (TestStepResult.TestStepStatus.FAILED.equals(testStepContext.getStatus())) {
        loggingContext.emit(asFunction(getStepError(testStepContext), "ERROR", Calendar.getInstance().getTime()));
    }
    if (TestStepResult.TestStepStatus.CANCELED.equals(testStepContext.getStatus())) {
        context.setTestCanceled(true);
    }
    if (!RpServiceBuilder.REPORTER_DISABLE) {
        String log = asMarkdown(String.format("# ===========STEP '%s' %s===========", testStepContext.getTestStep().getName(), TestStatus.fromSoapUIStep(testStepContext.getStatus())));
        loggingContext.emit(asFunction(log, LEVEL_INFO, Calendar.getInstance().getTime()));
    }
}
Also used : LoggingContext(com.epam.reportportal.service.LoggingContext) SaveLogRQ(com.epam.ta.reportportal.ws.model.log.SaveLogRQ)

Example 4 with LoggingContext

use of com.epam.reportportal.service.LoggingContext in project agent-java-soapui by reportportal.

the class CustomLoggerService method logFile.

public static void logFile(String message, File file, String level) throws IOException {
    if (TEST_CASE_ID != null) {
        byte[] fileContent = Files.readAllBytes(file.toPath());
        SaveLogRQ.File rqFile = new SaveLogRQ.File();
        rqFile.setContent(fileContent);
        rqFile.setContentType(Files.probeContentType(file.toPath()));
        rqFile.setName(UUID.randomUUID().toString());
        LoggingContext loggingContext = CONTEXT_MAP.get(TEST_CASE_ID);
        loggingContext.emit(asFunctionFile(message, rqFile, level, Calendar.getInstance().getTime()));
    }
}
Also used : LoggingContext(com.epam.reportportal.service.LoggingContext) SaveLogRQ(com.epam.ta.reportportal.ws.model.log.SaveLogRQ) File(java.io.File)

Example 5 with LoggingContext

use of com.epam.reportportal.service.LoggingContext in project agent-java-soapui by reportportal.

the class TestBasedSoapUIServiceImpl method startTestCase.

@Override
public void startTestCase(TestCase testCase, PropertyExpansionContext propertyContext) {
    Maybe<String> id = startItem(testCase.getName(), TestItemType.TEST_STEP, fromStringId(testCase.getTestSuite().getPropertyValue(ID)));
    testCase.setPropertyValue(ID, toStringId(id));
    LoggingContext loggingContext = LoggingContext.init(id, this.reportPortal.getClient());
    CONTEXT_MAP.put(TEST_CASE_ID = testCase.getId(), loggingContext);
}
Also used : LoggingContext(com.epam.reportportal.service.LoggingContext)

Aggregations

LoggingContext (com.epam.reportportal.service.LoggingContext)5 SaveLogRQ (com.epam.ta.reportportal.ws.model.log.SaveLogRQ)2 File (java.io.File)1