Search in sources :

Example 1 with AssertionErrorBuilder

use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifySql.

private void verifySql(int index, ExpectedSql expected, Annotation<?> actual) {
    int id = this.handler.getTcpDataSender().getSqlId(expected.getQuery());
    IntStringStringValue actualSql = (IntStringStringValue) actual.getValue();
    if (actualSql.getIntValue() != id) {
        String actualQuery = this.handler.getTcpDataSender().getSql(actualSql.getIntValue());
        AssertionErrorBuilder builder = new AssertionErrorBuilder(String.format("Annotation[%s].sqlId", index), id + ":" + expected.getQuery(), actualSql.getIntValue() + ": " + actualQuery);
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (!ObjectUtils.equals(actualSql.getStringValue1(), expected.getOutput())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(String.format("Annotation[%s].sql.output", index), expected.getOutput(), actualSql.getStringValue1());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
    if (!ObjectUtils.equals(actualSql.getStringValue2(), expected.getBindValuesAsString())) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder(String.format("Annotation[%s].sql.bindValues", index), expected.getBindValuesAsString(), actualSql.getStringValue2());
        builder.setComparison(expected, actual);
        builder.throwAssertionError();
    }
}
Also used : IntStringStringValue(com.navercorp.pinpoint.common.util.IntStringStringValue) AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder)

Example 2 with AssertionErrorBuilder

use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyTrace.

@Override
public void verifyTrace(ExpectedTrace... expectations) {
    if (ArrayUtils.isEmpty(expectations)) {
        throw new IllegalArgumentException("No expectations");
    }
    for (ExpectedTrace expected : expectations) {
        ResolvedExpectedTrace resolved = resolveExpectedTrace(expected, null);
        final Item<SpanType> actualItem = popItem();
        if (actualItem == null) {
            AssertionErrorBuilder builder = new AssertionErrorBuilder("actualItem is null", resolved, "null");
            builder.throwAssertionError();
        }
        final SpanType actual = actualItem.getValue();
        ActualTrace wrapped = ActualTraceFactory.wrap(actual);
        verifySpan(resolved, wrapped);
        verifyAsyncTraces(expected, wrapped);
    }
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) SpanType(com.navercorp.pinpoint.profiler.context.SpanType) AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder) ActualTrace(com.navercorp.pinpoint.test.wrapper.ActualTrace)

Example 3 with AssertionErrorBuilder

use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyTraceCount.

@Override
public void verifyTraceCount(int expected) {
    final int actual = getTraceCount();
    if (expected != actual) {
        AssertionErrorBuilder builder = new AssertionErrorBuilder("count", expected, actual);
        builder.throwAssertionError();
    }
}
Also used : AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder)

Example 4 with AssertionErrorBuilder

use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyAsyncTraces.

private void verifyAsyncTraces(ExpectedTrace expected, ActualTrace actual) throws AssertionError {
    final ExpectedTrace[] expectedAsyncTraces = expected.getAsyncTraces();
    if (expectedAsyncTraces != null && expectedAsyncTraces.length > 0) {
        Integer actualAsyncId = actual.getNextAsyncId();
        if (actualAsyncId == null) {
            AssertionErrorBuilder builder = new AssertionErrorBuilder("async traces triggered but nextAsyncId is null", Arrays.toString(expectedAsyncTraces), actualAsyncId);
            builder.setComparison(expected, actual);
            builder.throwAssertionError();
        }
        verifyDiscreteTraceBlock(expectedAsyncTraces, actualAsyncId);
    }
}
Also used : ExpectedTrace(com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace) AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder)

Example 5 with AssertionErrorBuilder

use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.

the class PluginVerifierExternalAdaptor method verifyIsLoggingTransactionInfo.

@Override
public void verifyIsLoggingTransactionInfo(LoggingInfo loggingInfo) {
    final Item<SpanType> item = popItem();
    if (item == null) {
        throw new AssertionError("Expected a Span isLoggingTransactionInfo value with [" + loggingInfo.getName() + "]" + " but loggingTransactionInfo value invalid.");
    }
    final TraceRoot traceRoot = item.getTraceRoot();
    final byte loggingTransactionInfo = traceRoot.getShared().getLoggingInfo();
    if (loggingTransactionInfo != loggingInfo.getCode()) {
        LoggingInfo code = LoggingInfo.searchByCode(loggingTransactionInfo);
        String codeName = getCodeName(code);
        AssertionErrorBuilder builder = new AssertionErrorBuilder("Span.isLoggingTransactionInfo value", loggingInfo.getName(), codeName);
        builder.setComparison(loggingInfo.getName(), codeName);
        builder.throwAssertionError();
    }
}
Also used : SpanType(com.navercorp.pinpoint.profiler.context.SpanType) AssertionErrorBuilder(com.navercorp.pinpoint.test.util.AssertionErrorBuilder) TraceRoot(com.navercorp.pinpoint.profiler.context.id.TraceRoot) LoggingInfo(com.navercorp.pinpoint.common.trace.LoggingInfo)

Aggregations

AssertionErrorBuilder (com.navercorp.pinpoint.test.util.AssertionErrorBuilder)13 ExpectedAnnotation (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedAnnotation)2 ExpectedTrace (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedTrace)2 DataType (com.navercorp.pinpoint.common.util.DataType)2 SpanType (com.navercorp.pinpoint.profiler.context.SpanType)2 ServiceInfo (com.navercorp.pinpoint.bootstrap.context.ServiceInfo)1 ExpectedSql (com.navercorp.pinpoint.bootstrap.plugin.test.ExpectedSql)1 AnnotationKey (com.navercorp.pinpoint.common.trace.AnnotationKey)1 LoggingInfo (com.navercorp.pinpoint.common.trace.LoggingInfo)1 ServiceType (com.navercorp.pinpoint.common.trace.ServiceType)1 IntStringStringValue (com.navercorp.pinpoint.common.util.IntStringStringValue)1 IntStringValue (com.navercorp.pinpoint.common.util.IntStringValue)1 Annotation (com.navercorp.pinpoint.profiler.context.Annotation)1 TraceRoot (com.navercorp.pinpoint.profiler.context.id.TraceRoot)1 DefaultApplicationContext (com.navercorp.pinpoint.profiler.context.module.DefaultApplicationContext)1 ActualTrace (com.navercorp.pinpoint.test.wrapper.ActualTrace)1