use of com.palantir.tritium.test.TestInterface in project tritium by palantir.
the class InstrumentationTest method testEmptyHandlers.
@Test
void testEmptyHandlers() {
TestInterface delegate = new TestImplementation();
TestInterface instrumented = Instrumentation.wrap(TestInterface.class, delegate, Collections.emptyList(), InstrumentationFilters.INSTRUMENT_NONE);
assertThat(instrumented).isEqualTo(delegate);
assertThat(Proxy.isProxyClass(instrumented.getClass())).isFalse();
}
use of com.palantir.tritium.test.TestInterface in project tritium by palantir.
the class InstrumentationTest method testFilterSkips.
@Test
void testFilterSkips(@Mock InvocationEventHandler<InvocationContext> mockHandler) {
TestInterface delegate = new TestImplementation();
TestInterface instrumented = Instrumentation.builder(TestInterface.class, delegate).withFilter(methodNameFilter("bulk")).withHandler(mockHandler).build();
when(mockHandler.isEnabled()).thenReturn(true);
instrumented.test();
verify(mockHandler).isEnabled();
verifyNoMoreInteractions(mockHandler);
}
use of com.palantir.tritium.test.TestInterface in project tritium by palantir.
the class InstrumentationTest method testToString_delegateWithoutInstrumentation.
@Test
void testToString_delegateWithoutInstrumentation(@Mock InvocationEventHandler<InvocationContext> mockHandler) {
TestInterface delegate = new TestImplementation();
TestInterface instrumented = Instrumentation.builder(TestInterface.class, delegate).withHandler(mockHandler).build();
assertThat(instrumented).asString().isEqualTo("com.palantir.tritium.test.TestImplementation");
verifyNoMoreInteractions(mockHandler);
}
use of com.palantir.tritium.test.TestInterface in project tritium by palantir.
the class InstrumentationTest method testEquals_sameInstance.
@Test
void testEquals_sameInstance() {
TestInterface proxy = Instrumentation.builder(TestInterface.class, new TestImplementation()).withPerformanceTraceLogging().build();
assertThat(proxy).isEqualTo(proxy);
}
use of com.palantir.tritium.test.TestInterface in project tritium by palantir.
the class InstrumentationTest method testFilterMatches.
@Test
void testFilterMatches(@Mock InvocationEventHandler<InvocationContext> mockHandler) throws Exception {
TestInterface delegate = new TestImplementation();
TestInterface instrumented = Instrumentation.builder(TestInterface.class, delegate).withFilter(methodNameFilter("bulk")).withHandler(mockHandler).build();
InvocationContext mockContext = mock(InvocationContext.class);
when(mockHandler.isEnabled()).thenReturn(true);
when(mockHandler.preInvocation(any(), any(Method.class), any(Object[].class))).thenReturn(mockContext);
ImmutableSet<String> testSet = ImmutableSet.of("test");
instrumented.bulk(testSet);
verify(mockHandler).isEnabled();
verify(mockHandler).preInvocation(instrumented, TestInterface.class.getDeclaredMethod("bulk", Set.class), new Object[] { testSet });
verify(mockHandler).onSuccess(mockContext, null);
verifyNoMoreInteractions(mockHandler);
}
Aggregations