Search in sources :

Example 6 with ExtensionMethod

use of org.jdbi.v3.core.extension.ExtensionMethod in project metrics by dropwizard.

the class SmartNameStrategyTest method updatesTimerForContextClass.

@Test
public void updatesTimerForContextClass() throws Exception {
    when(ctx.getExtensionMethod()).thenReturn(new ExtensionMethod(getClass(), getClass().getMethod("updatesTimerForContextClass")));
    collector.collect(TimeUnit.SECONDS.toNanos(3), ctx);
    String name = smartNameStrategy.getStatementName(ctx);
    assertThat(name).isEqualTo(name(getClass(), "updatesTimerForContextClass"));
    assertThat(getTimerMaxValue(name)).isEqualTo(3000000000L);
}
Also used : ExtensionMethod(org.jdbi.v3.core.extension.ExtensionMethod) Test(org.junit.Test)

Example 7 with ExtensionMethod

use of org.jdbi.v3.core.extension.ExtensionMethod in project metrics by dropwizard.

the class SmartNameStrategyTest method updatesTimerForSqlObjects.

@Test
public void updatesTimerForSqlObjects() throws Exception {
    when(ctx.getExtensionMethod()).thenReturn(new ExtensionMethod(getClass(), getClass().getMethod("updatesTimerForSqlObjects")));
    collector.collect(TimeUnit.SECONDS.toNanos(1), ctx);
    String name = smartNameStrategy.getStatementName(ctx);
    assertThat(name).isEqualTo(name(getClass(), "updatesTimerForSqlObjects"));
    assertThat(getTimerMaxValue(name)).isEqualTo(1000000000);
}
Also used : ExtensionMethod(org.jdbi.v3.core.extension.ExtensionMethod) Test(org.junit.Test)

Example 8 with ExtensionMethod

use of org.jdbi.v3.core.extension.ExtensionMethod in project metrics by dropwizard.

the class TimedAnnotationNameStrategyTest method testAnnotationOnMethod.

@Test
public void testAnnotationOnMethod() throws Exception {
    when(ctx.getExtensionMethod()).thenReturn(new ExtensionMethod(Foo.class, Foo.class.getMethod("update")));
    assertThat(timedAnnotationNameStrategy.getStatementName(ctx)).isEqualTo("com.codahale.metrics.jdbi3.strategies.TimedAnnotationNameStrategyTest$Foo.update");
}
Also used : ExtensionMethod(org.jdbi.v3.core.extension.ExtensionMethod) Test(org.junit.Test)

Example 9 with ExtensionMethod

use of org.jdbi.v3.core.extension.ExtensionMethod in project metrics by dropwizard.

the class TimedAnnotationNameStrategyTest method testAnnotationOnMethodWithCustomAbsoluteName.

@Test
public void testAnnotationOnMethodWithCustomAbsoluteName() throws Exception {
    when(ctx.getExtensionMethod()).thenReturn(new ExtensionMethod(Foo.class, Foo.class.getMethod("absoluteUpdate")));
    assertThat(timedAnnotationNameStrategy.getStatementName(ctx)).isEqualTo("absolute-update");
}
Also used : ExtensionMethod(org.jdbi.v3.core.extension.ExtensionMethod) Test(org.junit.Test)

Example 10 with ExtensionMethod

use of org.jdbi.v3.core.extension.ExtensionMethod in project metrics by dropwizard.

the class TimedAnnotationNameStrategyTest method testAnnotationOnMethodWithCustomName.

@Test
public void testAnnotationOnMethodWithCustomName() throws Exception {
    when(ctx.getExtensionMethod()).thenReturn(new ExtensionMethod(Foo.class, Foo.class.getMethod("customUpdate")));
    assertThat(timedAnnotationNameStrategy.getStatementName(ctx)).isEqualTo("com.codahale.metrics.jdbi3.strategies.TimedAnnotationNameStrategyTest$Foo.custom-update");
}
Also used : ExtensionMethod(org.jdbi.v3.core.extension.ExtensionMethod) Test(org.junit.Test)

Aggregations

ExtensionMethod (org.jdbi.v3.core.extension.ExtensionMethod)12 Test (org.junit.Test)9 ConfigRegistry (org.jdbi.v3.core.config.ConfigRegistry)2 Timed (com.codahale.metrics.annotation.Timed)1 Method (java.lang.reflect.Method)1 Callable (java.util.concurrent.Callable)1 HandleSupplier (org.jdbi.v3.core.extension.HandleSupplier)1 Before (org.junit.Before)1