Search in sources :

Example 91 with Status

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);
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Test(org.junit.Test)

Example 92 with Status

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);
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Test(org.junit.Test)

Example 93 with Status

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);
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Test(org.junit.Test)

Example 94 with Status

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);
}
Also used : Status(com.microsoft.z3.Status) BoolExpr(com.microsoft.z3.BoolExpr) Test(org.junit.Test)

Example 95 with Status

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;
    }
}
Also used : KeyValue(io.opentelemetry.proto.common.v1.KeyValue) Resource(io.opentelemetry.sdk.resources.Resource) Attributes(io.opentelemetry.api.common.Attributes) io.opentelemetry.api.trace(io.opentelemetry.api.trace) InstrumentationLibraryInfo(io.opentelemetry.sdk.common.InstrumentationLibraryInfo) Map(java.util.Map) Nullable(javax.annotation.Nullable) ContextKey(io.opentelemetry.context.ContextKey) Context(io.opentelemetry.context.Context) BaseEncoding(com.google.common.io.BaseEncoding) Collectors(java.util.stream.Collectors) Span(io.opentelemetry.proto.trace.v1.Span) AttributesBuilder(io.opentelemetry.api.common.AttributesBuilder) ByteString(com.google.protobuf.ByteString) TimeUnit(java.util.concurrent.TimeUnit) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) CollectionUtils(org.springframework.util.CollectionUtils) AttributeKey(io.opentelemetry.api.common.AttributeKey) SystemClock(io.opentelemetry.sdk.internal.SystemClock) SpanData(io.opentelemetry.sdk.trace.data.SpanData) VisibleForTesting(com.google.common.annotations.VisibleForTesting) AnyValue(io.opentelemetry.proto.common.v1.AnyValue) LinkData(io.opentelemetry.sdk.trace.data.LinkData) Status(io.opentelemetry.proto.trace.v1.Status) Collections(java.util.Collections) StringUtils(org.springframework.util.StringUtils) Status(io.opentelemetry.proto.trace.v1.Status) LinkData(io.opentelemetry.sdk.trace.data.LinkData) Attributes(io.opentelemetry.api.common.Attributes) ByteString(com.google.protobuf.ByteString) AttributeKey(io.opentelemetry.api.common.AttributeKey)

Aggregations

Status (com.microsoft.z3.Status)63 BoolExpr (com.microsoft.z3.BoolExpr)55 Test (org.junit.Test)49 Test (org.junit.jupiter.api.Test)20 Expr (com.microsoft.z3.Expr)10 IOException (java.io.IOException)10 JsonMapper.convertObjectToJsonString (com.arbindo.mimock.helpers.general.JsonMapper.convertObjectToJsonString)9 RandomDataGenerator.generateRandomAlphabeticString (com.arbindo.mimock.helpers.general.RandomDataGenerator.generateRandomAlphabeticString)9 Status (com.arbindo.mimock.manage.mimocks.models.v1.Status)9 Context (com.microsoft.z3.Context)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)9 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)9 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)9 Pageable (org.springframework.data.domain.Pageable)9 HttpStatus (org.springframework.http.HttpStatus)9 MvcResult (org.springframework.test.web.servlet.MvcResult)9 Mock (com.arbindo.mimock.entities.Mock)8 List (java.util.List)7 Solver (com.microsoft.z3.Solver)6 PageImpl (org.springframework.data.domain.PageImpl)6