use of org.aspectj.lang.ProceedingJoinPoint in project page-factory-2 by sbtqa.
the class DataAspect method run.
@Around("sendCaseStart(event)")
public Object run(ProceedingJoinPoint joinPoint, TestCaseStarted event) throws Throwable {
List<PickleTag> tags = event.testCase.getTags().stream().filter(pickleTag -> pickleTag.getName().startsWith(DataUtils.DATA_TAG)).collect(Collectors.toList());
if (!tags.isEmpty()) {
String dataTagName = tags.get(tags.size() - 1).getName();
String data = DataUtils.getDataTagValue(dataTagName);
for (TestStep testStep : event.testCase.getTestSteps()) {
if (!(testStep instanceof HookTestStep)) {
PickleStepTestStep pickleStepTestStep = (PickleStepTestStep) testStep;
PickleStepTag stepCustom = getPickleStepTag(pickleStepTestStep);
stepCustom.setDataTag(data);
replaceByPickleStepTag(pickleStepTestStep, stepCustom);
}
}
}
return joinPoint.proceed();
}
use of org.aspectj.lang.ProceedingJoinPoint in project iobserve-analysis by research-iobserve.
the class AbstractOperationExecutionWithParameterAspect method operation.
@Around("monitoredOperation() && this(thisObject) && notWithinKieker()")
public Object operation(final Object thisObject, final ProceedingJoinPoint thisJoinPoint) throws Throwable {
// (Throwable)
if (!AbstractOperationExecutionWithParameterAspect.CTRLINST.isMonitoringEnabled()) {
return thisJoinPoint.proceed();
}
final String operationSignature = this.signatureToLongString(thisJoinPoint.getSignature());
if (!AbstractOperationExecutionWithParameterAspect.CTRLINST.isProbeActivated(operationSignature)) {
return thisJoinPoint.proceed();
}
// common fields
TraceMetadata trace = AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.getTrace();
final boolean newTrace = trace == null;
if (newTrace) {
trace = AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.registerTrace();
AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(trace);
}
final long traceId = trace.getTraceId();
final String clazz = thisObject.getClass().getName();
/**
* extension over the original routine.
*/
final String[] names = ((MethodSignature) thisJoinPoint.getSignature()).getParameterNames();
final Object[] arguments = thisJoinPoint.getArgs();
final String[] values = new String[arguments.length];
int i = 0;
for (final Object argument : arguments) {
values[i++] = argument.toString();
}
/**
* exchanged return type.
*/
// measure before execution
AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(new EntryLevelBeforeOperationEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, names, values, 0));
// execution of the called method
final Object retval;
try {
retval = thisJoinPoint.proceed();
} catch (final Throwable th) {
// NOPMD NOCS (catch throw might ok here)
// measure after failed execution
AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(new AfterOperationFailedEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString()));
throw th;
} finally {
if (newTrace) {
// close the trace
AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.unregisterTrace();
}
}
// measure after successful execution
AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(new AfterOperationEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz));
return retval;
}
Aggregations