本文整理汇总了Java中com.epam.ta.reportportal.ws.model.log.SaveLogRQ类的典型用法代码示例。如果您正苦于以下问题:Java SaveLogRQ类的具体用法?Java SaveLogRQ怎么用?Java SaveLogRQ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SaveLogRQ类属于com.epam.ta.reportportal.ws.model.log包,在下文中一共展示了SaveLogRQ类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendLog
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
public static void sendLog(final String message, final String level, final File file) {
ReportPortal.emitLog(new Function<String, SaveLogRQ>() {
@Override
public SaveLogRQ apply(String item) {
SaveLogRQ rq = new SaveLogRQ();
rq.setMessage(message);
rq.setTestItemId(item);
rq.setLevel(level);
rq.setLogTime(Calendar.getInstance().getTime());
if (file != null) {
rq.setFile(file);
}
return rq;
}
});
}
示例2: sendReportPortalMsg
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
@Override
public void sendReportPortalMsg(final ITestResult result) {
ReportPortal.emitLog(new Function<String, SaveLogRQ>() {
@Override
public SaveLogRQ apply(String itemId) {
SaveLogRQ rq = new SaveLogRQ();
rq.setTestItemId(itemId);
rq.setLevel("ERROR");
rq.setLogTime(Calendar.getInstance().getTime());
if (result.getThrowable() != null) {
rq.setMessage(getStackTraceAsString(result.getThrowable()));
} else {
rq.setMessage("Test has failed without exception");
}
rq.setLogTime(Calendar.getInstance().getTime());
return rq;
}
});
}
示例3: reportTestItemFailure
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
@VisibleForTesting
void reportTestItemFailure(ReportableItemFootprint testItemFootprint, ErrorInfo errorInfo) {
SaveLogRQ saveLogRQ = new SaveLogRQ();
saveLogRQ.setLogTime(Calendar.getInstance().getTime());
saveLogRQ.setTestItemId(testItemFootprint.getId());
saveLogRQ.setMessage("Exception: " + ExceptionUtil.printStackTrace(errorInfo.getException()));
saveLogRQ.setLevel("ERROR");
try {
reportPortalService.log(saveLogRQ);
} catch (RestEndpointIOException ex) {
handleRpException(ex, "Unable to send message to Report Portal");
}
}
示例4: reportTestItemFailure
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
@Test
public void reportTestItemFailure() throws RestEndpointIOException {
String itemId = "Test item ID";
ArgumentCaptor<SaveLogRQ> requestCaptor = forClass(SaveLogRQ.class);
when(rpServiceMock.log(requestCaptor.capture())).thenReturn(null);
ReportableItemFootprint footprintMock = createGenericFootprintMock(itemId, null);
spockReporter.reportTestItemFailure(footprintMock, createErrorInfoMock(new Exception()));
verify(rpServiceMock, times(1)).log(any(SaveLogRQ.class));
verifyErrorLogRQ(requestCaptor.getValue(), itemId);
}
示例5: reportTestItemFailure_rpPostThrowsException
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
@Test
public void reportTestItemFailure_rpPostThrowsException() throws RestEndpointIOException {
SpockReporter spockReporterSpy = spy(spockReporter);
RestEndpointIOException rpException = new RestEndpointIOException("");
when(rpServiceMock.log(any(SaveLogRQ.class))).thenThrow(rpException);
ReportableItemFootprint footprintMock = createGenericFootprintMock("Test item ID", null);
spockReporterSpy.reportTestItemFailure(footprintMock, createErrorInfoMock(new Exception()));
verify(spockReporterSpy, times(1)).handleRpException(eq(rpException), anyString());
}
示例6: append
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
@Override
protected void append(final ILoggingEvent event) {
emitLog(new Function<String, com.epam.ta.reportportal.ws.model.log.SaveLogRQ>() {
@Override
public com.epam.ta.reportportal.ws.model.log.SaveLogRQ apply(String itemId) {
final String message = event.getFormattedMessage();
final String level = event.getLevel().toString();
final Date time = new Date(event.getTimeStamp());
SaveLogRQ rq = new SaveLogRQ();
rq.setLevel(level);
rq.setLogTime(time);
rq.setTestItemId(itemId);
try {
if (MESSAGE_PARSER.supports(message)) {
ReportPortalMessage rpMessage = MESSAGE_PARSER.parse(message);
TypeAwareByteSource data = rpMessage.getData();
com.epam.ta.reportportal.ws.model.log.SaveLogRQ.File file = new com.epam.ta.reportportal.ws.model.log.SaveLogRQ.File();
file.setContent(data.read());
file.setContentType(data.getMediaType());
file.setName(UUID.randomUUID().toString());
rq.setFile(file);
rq.setMessage(rpMessage.getMessage());
} else {
rq.setMessage(encoder.getLayout().doLayout(event));
}
} catch (Exception e) {
//skip
}
return rq;
}
});
}
示例7: finishTestStep
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
public void finishTestStep(TestStepResult testStepContext, TestCaseRunContext paramTestCaseRunContext) {
LoggingContext loggingContext = CONTEXT_MAP.get(testStepContext.getTestStep().getTestCase().getId());
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(@Nullable 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);
}
String log = asMarkdown(String.format("# ===========STEP '%s' %s===========", testStepContext.getTestStep().getName(),
TestStatus.fromSoapUIStep(testStepContext.getStatus())));
loggingContext.emit(asFunction(log, LEVEL_INFO, Calendar.getInstance().getTime()));
}
示例8: asFunction
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
private Function<String, SaveLogRQ> asFunction(final String message, final String level, final Date time) {
return new Function<String, SaveLogRQ>() {
@Override
public SaveLogRQ apply(@Nullable String id) {
SaveLogRQ rq = new SaveLogRQ();
rq.setLevel(level);
rq.setLogTime(time);
rq.setTestItemId(id);
rq.setMessage(message);
return rq;
}
};
}
示例9: getStepLogReport
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
protected List<SaveLogRQ> getStepLogReport(TestStepResult testStepContext) {
List<SaveLogRQ> rqs = new ArrayList<SaveLogRQ>();
for (ResultLogger<?> resultLogger : resultLoggers) {
if (resultLogger.supports(testStepContext)) {
rqs.addAll(resultLogger.buildLogs(testStepContext));
}
}
return rqs;
}
示例10: prepareLogs
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
@Override
protected List<SaveLogRQ> prepareLogs(HttpMessageExchange result) {
final HttpResponse testRS = (HttpResponse) result.getResponse();
return Arrays.asList(
prepareEntity( "REQUEST", testRS.getRequestHeaders().toString(), testRS.getRequestContent()),
prepareEntity("RESPONSE", testRS.getResponseHeaders().toString(), testRS.getContentAsString()));
}
示例11: prepareEntity
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
private SaveLogRQ prepareEntity(String prefix, String headers, String body) {
StringBuilder rqLog = new StringBuilder();
rqLog
.append(prefix).append("\n")
.append("HEADERS:\n")
.append(headers);
if (!isNullOrEmpty(body)) {
rqLog.append("BODY:\n")
.append(body);
}
return prepareEntity("INFO", rqLog.toString());
}
示例12: prepareEntity
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
protected final SaveLogRQ prepareEntity(String level, String message) {
SaveLogRQ logRQ = new SaveLogRQ();
logRQ.setLevel(level);
logRQ.setLogTime(Calendar.getInstance().getTime());
logRQ.setMessage(message);
return logRQ;
}
示例13: BatchedReportPortalService
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
public BatchedReportPortalService(final RestEndpoint endpoint, final String apiBase, final String project, final int logsBatchSize) {
super(endpoint, apiBase, project);
saveLogQueue = new ThreadLocal<BatchExecutor<SaveLogRQ, BatchElementCreatedRS>>() {
@Override
protected BatchExecutor<SaveLogRQ, BatchElementCreatedRS> initialValue() {
return new BatchExecutor<SaveLogRQ, BatchElementCreatedRS>() {
@Override
protected void executeBatch(Queue<BatchExecutor.Parameter<SaveLogRQ, BatchElementCreatedRS>> batch) throws IOException {
MultiPartRequest.Builder<List<SaveLogRQ>> requestBuilder = new MultiPartRequest.Builder<List<SaveLogRQ>>();
List<SaveLogRQ> serializedPart = new ArrayList<SaveLogRQ>(batch.size());
for (BatchExecutor.Parameter<SaveLogRQ, BatchElementCreatedRS> batchItem : batch) {
SaveLogRQ rq = batchItem.getParameter();
serializedPart.add(batchItem.getParameter());
if (null != rq.getFile()) {
requestBuilder.addBinaryPart(Constants.LOG_REQUEST_BINARY_PART, rq.getFile().getName(),
ContentType.APPLICATION_OCTET_STREAM.getMimeType(), rq.getFile().getContent());
}
}
requestBuilder.addSerializedPart(Constants.LOG_REQUEST_JSON_PART, serializedPart);
BatchSaveOperatingRS batchResponse = endpoint.post(apiBase + "/" + project + "/log", requestBuilder.build(),
BatchSaveOperatingRS.class);
for (BatchElementCreatedRS rsItem : batchResponse.getResponses()) {
batch.poll().getResult().set(rsItem);
}
}
@Override
protected boolean execute(Queue<BatchExecutor.Parameter<SaveLogRQ, BatchElementCreatedRS>> batch) throws IOException {
return batch.size() >= logsBatchSize;
}
};
}
};
}
示例14: verifyErrorLogRQ
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
private static void verifyErrorLogRQ(SaveLogRQ errorLogRQ, String originItemId) {
assertThat(errorLogRQ.getTestItemId(), equalTo(originItemId));
assertThat(errorLogRQ.getLevel(), equalTo("ERROR"));
assertThat(errorLogRQ.getMessage(), not(isEmptyString()));
}
示例15: buildLogs
import com.epam.ta.reportportal.ws.model.log.SaveLogRQ; //导入依赖的package包/类
public final List<SaveLogRQ> buildLogs(TestStepResult result) {
//noinspection unchecked
return prepareLogs((T) result);
}