Search in sources :

Example 6 with StaticAnalysisContext

use of fish.payara.microprofile.faulttolerance.policy.StaticAnalysisContext in project Payara by payara.

the class ConfigOverridePriorityTest method onlyMethodLevelAnnotationPresent.

@Test
public void onlyMethodLevelAnnotationPresent() {
    Method annotatedMethod = TestUtils.getAnnotatedMethod();
    FaultToleranceConfig config = configFactory.bindTo(new StaticAnalysisContext(getClass(), annotatedMethod));
    Timeout timeout = config.getAnnotation(Timeout.class);
    assertEquals(42L, config.value(timeout));
    overrides.override(Timeout.class, "value", 11L);
    assertEquals("should be: global override effective", 11L, config.value(timeout));
    overrides.override(getClass(), Timeout.class, "value", 22L);
    assertEquals("should be: class level override ineffective because no class level annotation present", 11L, config.value(timeout));
    // do method level override
    overrides.override(annotatedMethod, Timeout.class, "value", 33L);
    assertEquals("should be: method level override effective", 33L, config.value(timeout));
}
Also used : StaticAnalysisContext(fish.payara.microprofile.faulttolerance.policy.StaticAnalysisContext) Timeout(org.eclipse.microprofile.faulttolerance.Timeout) FaultToleranceConfig(fish.payara.microprofile.faulttolerance.FaultToleranceConfig) Method(java.lang.reflect.Method) Test(org.junit.Test)

Aggregations

StaticAnalysisContext (fish.payara.microprofile.faulttolerance.policy.StaticAnalysisContext)6 Method (java.lang.reflect.Method)6 FaultToleranceConfig (fish.payara.microprofile.faulttolerance.FaultToleranceConfig)5 Test (org.junit.Test)4 Retry (org.eclipse.microprofile.faulttolerance.Retry)3 TestUtils.getAnnotatedMethod (fish.payara.microprofile.faulttolerance.test.TestUtils.getAnnotatedMethod)1 Asynchronous (org.eclipse.microprofile.faulttolerance.Asynchronous)1 Timeout (org.eclipse.microprofile.faulttolerance.Timeout)1