use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project bmoth by hhu-stups.
the class QuantifiedFormulaEvaluationTest method testFailUniversalFormula.
@Test
public void testFailUniversalFormula() {
String formula = "!(x).(x=5)";
// getting the translated z3 representation of the formula
BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
z3Solver.add(constraint);
Status check = z3Solver.check();
assertEquals(Status.UNSATISFIABLE, check);
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project bmoth by hhu-stups.
the class QuantifiedFormulaEvaluationTest method testUniversalExistentialFormula.
@Test
public void testUniversalExistentialFormula() {
String formula = "#(y).(y:NATURAL & !(x).(x*y=y))";
// getting the translated z3 representation of the formula
BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
z3Solver.add(constraint);
Status check = z3Solver.check();
assertEquals(Status.SATISFIABLE, check);
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project bmoth by hhu-stups.
the class QuantifiedFormulaEvaluationTest method testFailExistentialFormula.
@Test
public void testFailExistentialFormula() {
String formula = "#(x).(x=2 & x=5)";
// getting the translated z3 representation of the formula
BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
z3Solver.add(constraint);
Status check = z3Solver.check();
assertEquals(Status.UNSATISFIABLE, check);
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project bmoth by hhu-stups.
the class QuantifiedFormulaEvaluationTest method testUniversalFormula.
@Test
public void testUniversalFormula() {
String formula = "!(x).(x=TRUE or x=FALSE)";
// getting the translated z3 representation of the formula
BoolExpr constraint = FormulaToZ3Translator.translatePredicate(formula, z3Context);
z3Solver.add(constraint);
Status check = z3Solver.check();
assertEquals(Status.SATISFIABLE, check);
}
use of fi.thl.covid19.exposurenotification.diagnosiskey.v1.Status in project inspectit-ocelot by inspectIT.
the class OcelotSpanUtils method createSpanData.
/**
* Creates a {@link SpanData} instance based on the given arguments.
*
* @param protoSpan the protobuf representation of the span
* @param resource the span's resources
* @param instrumentationLibraryInfo the information of the tracing library
* @param customSpanAttributes additional attributes which should be added to each span
*
* @return the created {@link SpanData} instance
*/
public static SpanData createSpanData(Span protoSpan, Resource resource, InstrumentationLibraryInfo instrumentationLibraryInfo, Map<String, String> customSpanAttributes) {
try {
String traceId = toIdString(protoSpan.getTraceId());
String spanId = toIdString(protoSpan.getSpanId());
String parentSpanId = toIdString(protoSpan.getParentSpanId());
SpanContext spanContext = createSpanContext(traceId, spanId);
SpanContext parentSpanContext = createSpanContext(traceId, parentSpanId);
// only create spans with valid context
if (!spanContext.isValid()) {
return null;
}
// span data
String name = protoSpan.getName();
long startTime = protoSpan.getStartTimeUnixNano();
SpanLimits spanLimits = SpanLimits.getDefault();
int totalRecordedLinks = protoSpan.getLinksCount() + protoSpan.getDroppedLinksCount();
SpanKind spanKind = toSpanKind(protoSpan.getKind());
List<LinkData> links = toLinkData(protoSpan.getLinksList());
// convert attributes map to AttributesMap
Attributes spanAttributes = toAttributes(protoSpan.getAttributesList(), customSpanAttributes);
Map<AttributeKey<?>, Object> attributesMap = spanAttributes.asMap();
AttributesMap spanAttributesMap = new AttributesMap(attributesMap.size());
spanAttributesMap.putAll(attributesMap);
// creating the actual span
RecordEventsReadableSpan span = RecordEventsReadableSpan.startSpan(spanContext, name, instrumentationLibraryInfo, spanKind, parentSpanContext, NOOP_CONTEXT, spanLimits, NOOP_SPAN_PROCESSOR, SystemClock.getInstance(), resource, spanAttributesMap, links, totalRecordedLinks, startTime);
// add events to the span - and filter events which occurred before the actual span
protoSpan.getEventsList().stream().filter(event -> event.getTimeUnixNano() >= span.getStartEpochNanos()).forEach(event -> {
Attributes attributes = toAttributes(event.getAttributesList());
span.addEvent(event.getName(), attributes, event.getTimeUnixNano(), TimeUnit.NANOSECONDS);
});
// the span's status code
Status status = protoSpan.getStatus();
StatusCode statusCode = toStatusCode(status.getCode());
if (statusCode != null) {
span.setStatus(statusCode, status.getMessage());
}
// set end time if available
long endTime = protoSpan.getEndTimeUnixNano();
if (endTime > 0) {
span.end(endTime, TimeUnit.NANOSECONDS);
}
return span.toSpanData();
} catch (Exception e) {
log.warn("Error converting OT proto span {} to span data.", protoSpan, e);
return null;
}
}
Aggregations