|
| 1 | +package datadog.trace.civisibility.events; |
| 2 | + |
| 3 | +import datadog.trace.api.civisibility.DDTest; |
| 4 | +import datadog.trace.api.civisibility.DDTestSuite; |
| 5 | +import datadog.trace.api.civisibility.config.TestIdentifier; |
| 6 | +import datadog.trace.api.civisibility.events.TestEventsHandler; |
| 7 | +import datadog.trace.api.civisibility.retry.TestRetryPolicy; |
| 8 | +import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation; |
| 9 | +import datadog.trace.bootstrap.ContextStore; |
| 10 | +import datadog.trace.civisibility.retry.NeverRetry; |
| 11 | +import java.lang.reflect.Method; |
| 12 | +import java.util.Collection; |
| 13 | +import org.jetbrains.annotations.NotNull; |
| 14 | +import org.jetbrains.annotations.Nullable; |
| 15 | + |
| 16 | +public class NoOpTestEventsHandler<SuiteKey, TestKey> |
| 17 | + implements TestEventsHandler<SuiteKey, TestKey> { |
| 18 | + |
| 19 | + @Override |
| 20 | + public void onTestSuiteStart( |
| 21 | + SuiteKey descriptor, |
| 22 | + String testSuiteName, |
| 23 | + @Nullable String testFramework, |
| 24 | + @Nullable String testFrameworkVersion, |
| 25 | + @Nullable Class<?> testClass, |
| 26 | + @Nullable Collection<String> categories, |
| 27 | + boolean parallelized, |
| 28 | + TestFrameworkInstrumentation instrumentation) { |
| 29 | + // do nothing |
| 30 | + } |
| 31 | + |
| 32 | + @Override |
| 33 | + public void onTestSuiteSkip(SuiteKey descriptor, @Nullable String reason) { |
| 34 | + // do nothing |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public void onTestSuiteFailure(SuiteKey descriptor, @Nullable Throwable throwable) { |
| 39 | + // do nothing |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public void onTestSuiteFinish(SuiteKey descriptor) { |
| 44 | + // do nothing |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public void onTestStart( |
| 49 | + SuiteKey suiteDescriptor, |
| 50 | + TestKey descriptor, |
| 51 | + String testSuiteName, |
| 52 | + String testName, |
| 53 | + @Nullable String testFramework, |
| 54 | + @Nullable String testFrameworkVersion, |
| 55 | + @Nullable String testParameters, |
| 56 | + @Nullable Collection<String> categories, |
| 57 | + @Nullable Class<?> testClass, |
| 58 | + @Nullable String testMethodName, |
| 59 | + @Nullable Method testMethod, |
| 60 | + boolean isRetry) { |
| 61 | + // do nothing |
| 62 | + } |
| 63 | + |
| 64 | + @Override |
| 65 | + public void onTestSkip(TestKey descriptor, @Nullable String reason) { |
| 66 | + // do nothing |
| 67 | + } |
| 68 | + |
| 69 | + @Override |
| 70 | + public void onTestFailure(TestKey descriptor, @Nullable Throwable throwable) { |
| 71 | + // do nothing |
| 72 | + } |
| 73 | + |
| 74 | + @Override |
| 75 | + public void onTestFinish(TestKey descriptor) { |
| 76 | + // do nothing |
| 77 | + } |
| 78 | + |
| 79 | + @Override |
| 80 | + public void onTestIgnore( |
| 81 | + SuiteKey suiteDescriptor, |
| 82 | + TestKey testDescriptor, |
| 83 | + String testSuiteName, |
| 84 | + String testName, |
| 85 | + @Nullable String testFramework, |
| 86 | + @Nullable String testFrameworkVersion, |
| 87 | + @Nullable String testParameters, |
| 88 | + @Nullable Collection<String> categories, |
| 89 | + @Nullable Class<?> testClass, |
| 90 | + @Nullable String testMethodName, |
| 91 | + @Nullable Method testMethod, |
| 92 | + @Nullable String reason) { |
| 93 | + // do nothing |
| 94 | + } |
| 95 | + |
| 96 | + @Override |
| 97 | + public boolean skip(TestIdentifier test) { |
| 98 | + return false; |
| 99 | + } |
| 100 | + |
| 101 | + @Override |
| 102 | + public boolean shouldBeSkipped(TestIdentifier test) { |
| 103 | + return false; |
| 104 | + } |
| 105 | + |
| 106 | + @NotNull |
| 107 | + @Override |
| 108 | + public TestRetryPolicy retryPolicy(TestIdentifier test) { |
| 109 | + return NeverRetry.INSTANCE; |
| 110 | + } |
| 111 | + |
| 112 | + @Override |
| 113 | + public boolean isNew(TestIdentifier test) { |
| 114 | + return false; |
| 115 | + } |
| 116 | + |
| 117 | + @Override |
| 118 | + public boolean isFlaky(TestIdentifier test) { |
| 119 | + return false; |
| 120 | + } |
| 121 | + |
| 122 | + @Override |
| 123 | + public void close() { |
| 124 | + // do nothing |
| 125 | + } |
| 126 | + |
| 127 | + public static final class Factory implements TestEventsHandler.Factory { |
| 128 | + @Override |
| 129 | + public <SuiteKey, TestKey> TestEventsHandler<SuiteKey, TestKey> create( |
| 130 | + String component, |
| 131 | + @Nullable ContextStore<SuiteKey, DDTestSuite> suiteStore, |
| 132 | + @Nullable ContextStore<TestKey, DDTest> testStore) { |
| 133 | + return new NoOpTestEventsHandler<>(); |
| 134 | + } |
| 135 | + } |
| 136 | +} |
0 commit comments