use of com.evolveum.midpoint.schema.result.CompiledTracingProfile in project midpoint by Evolveum.
the class TestModelServiceContract method test103GetAccountRaw.
/**
* MID-6716
*/
@Test
public void test103GetAccountRaw() throws Exception {
given();
Task task = getTestTask();
OperationResult parentResult = task.getResult();
preTestCleanup(AssignmentPolicyEnforcementType.POSITIVE);
Collection<SelectorOptions<GetOperationOptions>> options = schemaService.getOperationOptionsBuilder().raw().build();
when();
// Just to avoid result pruning.
CompiledTracingProfile tracingProfile = tracer.compileProfile(new TracingProfileType(prismContext).createTraceFile(false), parentResult);
OperationResult result = parentResult.subresult("get").tracingProfile(tracingProfile).build();
PrismObject<ShadowType> account = modelService.getObject(ShadowType.class, accountJackOid, options, task, result);
then();
display("Account", account);
displayDumpable("Account def", account.getDefinition());
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0);
PrismContainer<Containerable> accountContainer = account.findContainer(ShadowType.F_ATTRIBUTES);
displayDumpable("Account attributes def", accountContainer.getDefinition());
displayDumpable("Account attributes def complex type def", accountContainer.getDefinition().getComplexTypeDefinition());
assertDummyAccountShadowRepo(account, accountJackOid, "jack");
assertSuccess("getObject result", result);
assertSteadyResources();
displayDumpable("result", result);
List<String> provisioningOperations = result.getResultStream().map(OperationResult::getOperation).filter(operation -> operation.startsWith(ProvisioningService.class.getName())).collect(Collectors.toList());
assertThat(provisioningOperations).as("provisioning operations").isEmpty();
}
use of com.evolveum.midpoint.schema.result.CompiledTracingProfile in project midpoint by Evolveum.
the class AbstractIntegrationTest method startTestContext.
/**
* Creates test method context which includes customized {@link Task}
* (see {@link #createTask(String)}) and other test related info wrapped as
* {@link MidpointTestContextWithTask} and stores it in thread-local variable for future access.
* This implementation fully overrides version from {@link AbstractSpringTest}.
*/
@Override
@BeforeMethod
public void startTestContext(ITestResult testResult) throws SchemaException {
Class<?> testClass = testResult.getMethod().getTestClass().getRealClass();
String testMethodName = testResult.getMethod().getMethodName();
String testName = testClass.getSimpleName() + "." + testMethodName;
displayTestTitle(testName);
Task task = createTask(testMethodName);
TracingProfileType tracingProfile = getTestMethodTracingProfile();
if (tracingProfile != null) {
CompiledTracingProfile compiledTracingProfile = tracer.compileProfile(tracingProfile, task.getResult());
task.getResult().tracingProfile(compiledTracingProfile);
}
MidpointTestContextWithTask.create(testClass, testMethodName, task, task.getResult());
tracer.setTemplateParametersCustomizer(params -> {
params.put(MACRO_TEST_NAME_TRACER_PARAM, testName);
params.put(MACRO_TEST_NAME_SHORT_TRACER_PARAM, testMethodName);
});
}
use of com.evolveum.midpoint.schema.result.CompiledTracingProfile in project midpoint by Evolveum.
the class TracerImpl method storeTrace.
@Override
public void storeTrace(Task task, OperationResult result, @Nullable OperationResult parentResult) {
OperationResult thisOpResult;
if (parentResult != null) {
thisOpResult = parentResult.createMinorSubresult(OP_STORE_TRACE);
} else {
thisOpResult = new OperationResult(OP_STORE_TRACE);
}
try {
CompiledTracingProfile compiledTracingProfile = result.getTracingProfile();
TracingProfileType tracingProfile = compiledTracingProfile.getDefinition();
if (!Boolean.FALSE.equals(tracingProfile.isCreateTraceFile())) {
boolean zip = !Boolean.FALSE.equals(tracingProfile.isCompressOutput());
// todo evaluate lazily if needed
Map<String, String> templateParameters = createTemplateParameters(result);
File file = createFileName(zip, tracingProfile, templateParameters);
try {
long start = System.currentTimeMillis();
TracingOutputType tracingOutput = tracingOutputCreator.createTracingOutput(task, result, tracingProfile);
String xml = new TraceWriter(prismContext).writeTrace(tracingOutput, file, zip);
if (zip) {
LOGGER.info("Trace was written to {} ({} chars uncompressed) in {} milliseconds", file, xml.length(), System.currentTimeMillis() - start);
} else {
LOGGER.info("Trace was written to {} ({} chars) in {} milliseconds", file, xml.length(), System.currentTimeMillis() - start);
}
if (!Boolean.FALSE.equals(tracingProfile.isCreateRepoObject())) {
ReportDataType reportDataObject = new ReportDataType(prismContext).name(createObjectName(tracingProfile, templateParameters)).archetypeRef(SystemObjectsType.ARCHETYPE_TRACE.value(), ArchetypeType.COMPLEX_TYPE).filePath(file.getAbsolutePath()).nodeRef(ObjectTypeUtil.createObjectRef(taskManager.getLocalNode(), prismContext));
repositoryService.addObject(reportDataObject.asPrismObject(), null, thisOpResult);
}
} catch (IOException | SchemaException | ObjectAlreadyExistsException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't write trace ({})", e, file);
throw new SystemException(e);
}
}
} catch (Throwable t) {
thisOpResult.recordFatalError(t);
throw t;
} finally {
thisOpResult.computeStatusIfUnknown();
}
}
Aggregations