use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.
the class PluginVerifierExternalAdaptor method verifySpan.
private void verifySpan(final ResolvedExpectedTrace expected, ActualTrace actual) {
if (!expected.type.equals(actual.getType())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + " InstanceType", expected.type.getSimpleName(), actual.getType().getName());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.serviceType.getCode(), actual.getServiceType())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".serviceType", expected.serviceType.getCode(), actual.getServiceType());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.apiId, actual.getApiId())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".apiId", expected.apiId, actual.getApiId());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.rpc, actual.getRpc())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".rpc", expected.rpc, actual.getRpc());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.endPoint, actual.getEndPoint())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".endPoint", expected.endPoint, actual.getEndPoint());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.remoteAddr, actual.getRemoteAddr())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".remoteAddr", expected.remoteAddr, actual.getRemoteAddr());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(expected.destinationId, actual.getDestinationId())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".destinationId", expected.destinationId, actual.getDestinationId());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (!equals(getAsyncId(expected), actual.getAsyncId())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".asyncId", expected.localAsyncId, actual.getAsyncId());
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (expected.exception != null) {
final IntStringValue actualExceptionInfo = actual.getExceptionInfo();
if (actualExceptionInfo != null) {
String actualExceptionClassName = this.handler.getTcpDataSender().getString(actualExceptionInfo.getIntValue());
String actualExceptionMessage = actualExceptionInfo.getStringValue();
verifyException(expected.exception, actualExceptionClassName, actualExceptionMessage);
} else {
AssertionErrorBuilder builder = new AssertionErrorBuilder(expected.type.getSimpleName() + ".exception", expected.exception.getClass().getName(), null);
builder.throwAssertionError();
}
}
List<Annotation<?>> actualAnnotations = actual.getAnnotations();
final int expectedLen = ArrayUtils.getLength(expected.annotations);
final int actualLen = CollectionUtils.nullSafeSize(actualAnnotations);
if (actualLen != expectedLen) {
AssertionErrorBuilder builder = new AssertionErrorBuilder("Annotation.length", expectedLen, actualLen);
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
for (int i = 0; i < expectedLen; i++) {
annotationCompare(i, expected, actual, actualAnnotations.get(i));
}
}
use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.
the class PluginVerifierExternalAdaptor method verifyServerType.
@Override
public void verifyServerType(String serviceTypeName) {
final DefaultApplicationContext applicationContext = getApplicationContext();
ServiceType expectedType = findServiceType(serviceTypeName);
ServiceType actualType = applicationContext.getAgentInformation().getServerType();
if (!expectedType.equals(actualType)) {
AssertionErrorBuilder builder = new AssertionErrorBuilder("serverType", expectedType, actualType);
builder.throwAssertionError();
}
}
use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.
the class PluginVerifierExternalAdaptor method verifyDataType.
private void verifyDataType(int index, DataType expectedValue, Annotation<?> actualAnnotation) {
DataType annotationValue = (DataType) actualAnnotation.getValue();
if (!ObjectUtils.equals(expectedValue, annotationValue)) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(String.format("Annotation[%s].value", index), expectedValue, annotationValue);
builder.throwAssertionError();
}
}
use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.
the class PluginVerifierExternalAdaptor method annotationCompare.
private void annotationCompare(int index, ResolvedExpectedTrace expected, ActualTrace actual, Annotation<?> actualAnnotation) {
final ExpectedAnnotation expect = expected.annotations[index];
final AnnotationKey expectedAnnotationKey = this.handler.getAnnotationKeyRegistryService().findAnnotationKeyByName(expect.getKeyName());
if (expectedAnnotationKey.getCode() != actualAnnotation.getKey()) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(String.format("Annotation[%s].key", index), AnnotationUtils.toString(expectedAnnotationKey, expect), AnnotationUtils.toString(actualAnnotation));
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
if (expectedAnnotationKey == AnnotationKey.SQL_ID && expect instanceof ExpectedSql) {
verifySql(index, (ExpectedSql) expect, actualAnnotation);
} else if (expect.getValue() instanceof DataType) {
verifyDataType(index, ((DataType) expect.getValue()), actualAnnotation);
} else {
Object expectedValue = expect.getValue();
if (expectedValue == Expectations.anyAnnotationValue()) {
return;
}
if (AnnotationKeyUtils.isCachedArgsKey(expectedAnnotationKey.getCode())) {
expectedValue = this.handler.getTcpDataSender().getStringId(expectedValue.toString());
}
if (!ObjectUtils.equals(expectedValue, actualAnnotation.getValue())) {
AssertionErrorBuilder builder = new AssertionErrorBuilder(String.format("Annotation[%s].value", index), expectedAnnotationKey.getCode(), AnnotationUtils.toString(actualAnnotation));
builder.setComparison(expected, actual);
builder.throwAssertionError();
}
}
}
use of com.navercorp.pinpoint.test.util.AssertionErrorBuilder in project pinpoint by naver.
the class PluginVerifierExternalAdaptor method verifyServerInfo.
@Override
public void verifyServerInfo(String serverInfo) {
String actualName = getServerMetaData().getServerInfo();
if (!actualName.equals(serverInfo)) {
AssertionErrorBuilder builder = new AssertionErrorBuilder("serverInfo", serverInfo, actualName);
builder.throwAssertionError();
}
}
Aggregations