Java Code Examples for org.springframework.core.Ordered

The following examples show how to use org.springframework.core.Ordered. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Bean
public HandlerMapping webSocketMessagingHandlerMapping(MessagingManager messagingManager,
                                       UserTokenManager userTokenManager,
                                       ReactiveAuthenticationManager authenticationManager) {


    WebSocketMessagingHandler messagingHandler=new WebSocketMessagingHandler(
        messagingManager,
        userTokenManager,
        authenticationManager
    );
    final Map<String, WebSocketHandler> map = new HashMap<>(1);
    map.put("/messaging/**", messagingHandler);

    final SimpleUrlHandlerMapping mapping = new SimpleUrlHandlerMapping();
    mapping.setOrder(Ordered.HIGHEST_PRECEDENCE);
    mapping.setUrlMap(map);
    return mapping;
}
 
Example 2
Source Project: java-technology-stack   Source File: MvcNamespaceTests.java    License: MIT License 6 votes vote down vote up
@Test
public void testViewResolutionWithContentNegotiation() throws Exception {
	loadBeanDefinitions("mvc-config-view-resolution-content-negotiation.xml");

	ViewResolverComposite compositeResolver = this.appContext.getBean(ViewResolverComposite.class);
	assertNotNull(compositeResolver);
	assertEquals(1, compositeResolver.getViewResolvers().size());
	assertEquals(Ordered.HIGHEST_PRECEDENCE, compositeResolver.getOrder());

	List<ViewResolver> resolvers = compositeResolver.getViewResolvers();
	assertEquals(ContentNegotiatingViewResolver.class, resolvers.get(0).getClass());
	ContentNegotiatingViewResolver cnvr = (ContentNegotiatingViewResolver) resolvers.get(0);
	assertEquals(6, cnvr.getViewResolvers().size());
	assertEquals(1, cnvr.getDefaultViews().size());
	assertTrue(cnvr.isUseNotAcceptableStatusCode());

	String beanName = "contentNegotiationManager";
	DirectFieldAccessor accessor = new DirectFieldAccessor(cnvr);
	ContentNegotiationManager manager = (ContentNegotiationManager) accessor.getPropertyValue(beanName);
	assertNotNull(manager);
	assertSame(manager, this.appContext.getBean(ContentNegotiationManager.class));
	assertSame(manager, this.appContext.getBean("mvcContentNegotiationManager"));
}
 
Example 3
@Order(Ordered.HIGHEST_PRECEDENCE)
@Bean
public ComponentCustomizer<EhcacheComponent> customizer() {
    return new ComponentCustomizer<EhcacheComponent>() {
        @Override
        public void customize(EhcacheComponent component) {
            component.addCachesConfigurations(Collections.singletonMap(
                CACHE_CONFIG_ID,
                CacheConfigurationBuilder.newCacheConfigurationBuilder(
                    String.class,
                    String.class,
                    ResourcePoolsBuilder.newResourcePoolsBuilder()
                        .heap(2100, EntryUnit.ENTRIES)
                        .offheap(2, MemoryUnit.MB))
                    .build()
            ));
        }
    };
}
 
Example 4
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public Jackson2ObjectMapperBuilderCustomizer customJackson() {
    return new Jackson2ObjectMapperBuilderCustomizer() {
        @Override
        public void customize(Jackson2ObjectMapperBuilder builder) {
            builder.serializerByType(LocalDateTime.class,
                    new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            builder.serializerByType(LocalDate.class,
                    new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            builder.serializerByType(LocalTime.class,
                    new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
            builder.deserializerByType(LocalDateTime.class,
                    new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            builder.deserializerByType(LocalDate.class,
                    new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            builder.deserializerByType(LocalTime.class,
                    new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
            builder.serializationInclusion(JsonInclude.Include.NON_NULL);
            builder.failOnUnknownProperties(false);
            builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        }
    };
}
 
Example 5
Source Project: java-technology-stack   Source File: DispatcherHandlerTests.java    License: MIT License 6 votes vote down vote up
@Test
public void handlerMappingOrder() {
	HandlerMapping hm1 = mock(HandlerMapping.class, withSettings().extraInterfaces(Ordered.class));
	HandlerMapping hm2 = mock(HandlerMapping.class, withSettings().extraInterfaces(Ordered.class));
	when(((Ordered) hm1).getOrder()).thenReturn(1);
	when(((Ordered) hm2).getOrder()).thenReturn(2);
	when((hm1).getHandler(any())).thenReturn(Mono.just((Supplier<String>) () -> "1"));
	when((hm2).getHandler(any())).thenReturn(Mono.just((Supplier<String>) () -> "2"));

	StaticApplicationContext context = new StaticApplicationContext();
	context.registerBean("b2", HandlerMapping.class, () -> hm2);
	context.registerBean("b1", HandlerMapping.class, () -> hm1);
	context.registerBean(HandlerAdapter.class, SupplierHandlerAdapter::new);
	context.registerBean(HandlerResultHandler.class, StringHandlerResultHandler::new);
	context.refresh();

	DispatcherHandler dispatcherHandler = new DispatcherHandler(context);

	MockServerWebExchange exchange = MockServerWebExchange.from(MockServerHttpRequest.get("/"));
	dispatcherHandler.handle(exchange).block(Duration.ofSeconds(0));
	assertEquals("1", exchange.getResponse().getBodyAsString().block(Duration.ofSeconds(5)));
}
 
Example 6
Source Project: java-technology-stack   Source File: AopConfigUtils.java    License: MIT License 6 votes vote down vote up
@Nullable
private static BeanDefinition registerOrEscalateApcAsRequired(
		Class<?> cls, BeanDefinitionRegistry registry, @Nullable Object source) {

	Assert.notNull(registry, "BeanDefinitionRegistry must not be null");

	if (registry.containsBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME)) {
		BeanDefinition apcDefinition = registry.getBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME);
		if (!cls.getName().equals(apcDefinition.getBeanClassName())) {
			int currentPriority = findPriorityForClass(apcDefinition.getBeanClassName());
			int requiredPriority = findPriorityForClass(cls);
			if (currentPriority < requiredPriority) {
				apcDefinition.setBeanClassName(cls.getName());
			}
		}
		return null;
	}

	RootBeanDefinition beanDefinition = new RootBeanDefinition(cls);
	beanDefinition.setSource(source);
	beanDefinition.getPropertyValues().add("order", Ordered.HIGHEST_PRECEDENCE);
	beanDefinition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
	registry.registerBeanDefinition(AUTO_PROXY_CREATOR_BEAN_NAME, beanDefinition);
	return beanDefinition;
}
 
Example 7
@Bean(name = "aggregateQueryInterceptorChain")
@ConditionalOnMissingBean(AggregateQueryInterceptorChain.class)
public AggregateQueryInterceptorChain aggregateQueryInterceptorChain() {
    Map<String, AggregateQueryInterceptor> interceptorMap = applicationContext.getBeansOfType(AggregateQueryInterceptor.class);
    AggregateQueryInterceptorChainImpl interceptorChain = new AggregateQueryInterceptorChainImpl();
    if(interceptorMap != null  && ! interceptorMap.isEmpty()) {
        List<AggregateQueryInterceptor> interceptors = new ArrayList<>(interceptorMap.values());
        interceptors.sort(new Comparator<AggregateQueryInterceptor>() {
            @Override
            public int compare(AggregateQueryInterceptor o1, AggregateQueryInterceptor o2) {
                Order order1 = o1.getClass().getAnnotation(Order.class);
                Order order2 = o2.getClass().getAnnotation(Order.class);
                int oi1 = order1 == null ? Ordered.LOWEST_PRECEDENCE :  order1.value();
                int oi2 = order2 == null ?  Ordered.LOWEST_PRECEDENCE : order2.value();
                return oi1 - oi2;
            }
        });
        for (AggregateQueryInterceptor interceptor : interceptors) {
            interceptorChain.addInterceptor(interceptor);
        }
    }
    return interceptorChain;
}
 
Example 8
Source Project: open-cloud   Source File: GatewayConfiguration.java    License: MIT License 6 votes vote down vote up
/**
 * 跨域配置
 *
 * @return
 */
@Bean
public FilterRegistrationBean corsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.setAllowedHeaders(Lists.newArrayList(ALLOWED_HEADERS.split(",")));
    config.setAllowedOrigins(Lists.newArrayList(ALLOWED_ORIGIN.split(",")));
    config.setAllowedMethods(Lists.newArrayList(ALLOWED_METHODS.split(",")));
    config.setMaxAge(MAX_AGE);
    config.addExposedHeader(ALLOWED_EXPOSE);

    source.registerCorsConfiguration("/**", config);
    FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    //最大优先级,设置0不好使
    bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
    log.info("CorsFilter [{}]", bean);
    return bean;
}
 
Example 9
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public Jackson2ObjectMapperBuilderCustomizer customJackson() {
	return new Jackson2ObjectMapperBuilderCustomizer() {
		@Override
		public void customize(Jackson2ObjectMapperBuilder builder) {
			builder.serializerByType(LocalDateTime.class,
					new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
			builder.serializerByType(LocalDate.class,
					new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
			builder.serializerByType(LocalTime.class,
					new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));

			builder.deserializerByType(LocalDateTime.class,
					new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
			builder.deserializerByType(LocalDate.class,
					new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
			builder.deserializerByType(LocalTime.class,
					new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
			builder.serializationInclusion(JsonInclude.Include.NON_NULL);
			builder.failOnUnknownProperties(false);
			builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
		}
	};
}
 
Example 10
Source Project: mall   Source File: JacksonConfig.java    License: MIT License 6 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public Jackson2ObjectMapperBuilderCustomizer customJackson() {
    return new Jackson2ObjectMapperBuilderCustomizer() {
        @Override
        public void customize(Jackson2ObjectMapperBuilder builder) {
            builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            builder.serializerByType(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            builder.serializerByType(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));

            builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            builder.deserializerByType(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
            builder.deserializerByType(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
            builder.serializationInclusion(JsonInclude.Include.NON_NULL);
            builder.failOnUnknownProperties(false);
            builder.featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
        }
    };
}
 
Example 11
Source Project: sk-admin   Source File: SwaggerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public AlternateTypeRuleConvention pageableConvention(final TypeResolver resolver) {
    return new AlternateTypeRuleConvention() {
        @Override
        public int getOrder() {
            return Ordered.HIGHEST_PRECEDENCE;
        }

        @Override
        public List<AlternateTypeRule> rules() {
            return newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class)));
        }
    };
}
 
Example 12
Source Project: java-technology-stack   Source File: ViewResolverRegistryTests.java    License: MIT License 5 votes vote down vote up
@Test
public void contentNegotiation() {
	MappingJackson2JsonView view = new MappingJackson2JsonView();
	this.registry.enableContentNegotiation(view);
	ContentNegotiatingViewResolver resolver = checkAndGetResolver(ContentNegotiatingViewResolver.class);
	assertEquals(Arrays.asList(view), resolver.getDefaultViews());
	assertEquals(Ordered.HIGHEST_PRECEDENCE, this.registry.getOrder());
}
 
Example 13
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
	GlobalExceptionHandler exceptionHandler = new GlobalExceptionHandler(
			errorAttributes,
			this.resourceProperties,
			this.serverProperties.getError(),
			this.applicationContext);
	exceptionHandler.setViewResolvers(this.viewResolvers);
	exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
	exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
	return exceptionHandler;
}
 
Example 14
Source Project: mPass   Source File: TransactionUtil.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public int getOrder() {
	if (runner instanceof Ordered) {
		return ((Ordered) runner).getOrder();
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example 15
Source Project: staffjoy   Source File: FaradayConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean<NakedDomainFilter> nakedDomainFilterRegistrationBean(EnvConfig envConfig) {
    FilterRegistrationBean<NakedDomainFilter> registrationBean =
            new FilterRegistrationBean<>(new NakedDomainFilter(envConfig));
    registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 90); // before ReverseProxyFilter
    return registrationBean;
}
 
Example 16
Source Project: staffjoy   Source File: FaradayConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean<SecurityFilter> securityFilterRegistrationBean(EnvConfig envConfig) {
    FilterRegistrationBean<SecurityFilter> registrationBean =
            new FilterRegistrationBean<>(new SecurityFilter(envConfig));
    registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 80); // before nakedDomainFilter
    return registrationBean;
}
 
Example 17
Source Project: staffjoy   Source File: FaradayConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public FilterRegistrationBean<FaviconFilter> faviconFilterRegistrationBean() {
    FilterRegistrationBean<FaviconFilter> registrationBean =
            new FilterRegistrationBean<>(new FaviconFilter(assetLoader.getFaviconFile()));
    registrationBean.setOrder(Ordered.HIGHEST_PRECEDENCE + 75); // before securityFilter
    return registrationBean;
}
 
Example 18
/**
 * Determine the order for this factory's target aspect, either
 * an instance-specific order expressed through implementing the
 * {@link org.springframework.core.Ordered} interface (only
 * checked for singleton beans), or an order expressed through the
 * {@link org.springframework.core.annotation.Order} annotation
 * at the class level.
 * @see org.springframework.core.Ordered
 * @see org.springframework.core.annotation.Order
 */
@Override
public int getOrder() {
	Class<?> type = this.beanFactory.getType(this.name);
	if (type != null) {
		if (Ordered.class.isAssignableFrom(type) && this.beanFactory.isSingleton(this.name)) {
			return ((Ordered) this.beanFactory.getBean(this.name)).getOrder();
		}
		return OrderUtils.getOrder(type, Ordered.LOWEST_PRECEDENCE);
	}
	return Ordered.LOWEST_PRECEDENCE;
}
 
Example 19
Source Project: MyShopPlus   Source File: ExceptionConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Primary
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ObjectProvider<List<ViewResolver>> viewResolversProvider, ServerCodecConfigurer serverCodecConfigurer) {
    JsonExceptionHandler jsonExceptionHandler = new JsonExceptionHandler();
    jsonExceptionHandler.setViewResolvers(viewResolversProvider.getIfAvailable(Collections::emptyList));
    jsonExceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters());
    jsonExceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders());
    return jsonExceptionHandler;
}
 
Example 20
Source Project: java-technology-stack   Source File: EnableAsyncTests.java    License: MIT License 5 votes vote down vote up
@Test
public void asyncProcessorIsOrderedLowestPrecedenceByDefault() {
	AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
	ctx.register(AsyncConfig.class);
	ctx.refresh();

	AsyncAnnotationBeanPostProcessor bpp = ctx.getBean(AsyncAnnotationBeanPostProcessor.class);
	assertThat(bpp.getOrder(), is(Ordered.LOWEST_PRECEDENCE));

	ctx.close();
}
 
Example 21
Source Project: yshopmall   Source File: SwaggerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public AlternateTypeRuleConvention pageableConvention(final TypeResolver resolver) {
    return new AlternateTypeRuleConvention() {
        @Override
        public int getOrder() {
            return Ordered.HIGHEST_PRECEDENCE;
        }

        @Override
        public List<AlternateTypeRule> rules() {
            return newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class)));
        }
    };
}
 
Example 22
@Bean
public FilterRegistrationBean<CorsFilter> simpleCorsFilter() {
    UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(true);
    config.setAllowedOrigins(Collections.singletonList("*"));
    config.setAllowedMethods(Collections.singletonList("*"));
    config.setAllowedHeaders(Collections.singletonList("*"));
    source.registerCorsConfiguration("/**", config);
    FilterRegistrationBean<CorsFilter> bean = new FilterRegistrationBean<>(new CorsFilter(source));
    bean.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return bean;
}
 
Example 23
@Order(Ordered.HIGHEST_PRECEDENCE)
@Bean
public ComponentCustomizer<InfinispanComponent> customizer() {
    return new ComponentCustomizer<InfinispanComponent>() {
        @Override
        public void customize(InfinispanComponent component) {
            component.getConfiguration().setCacheContainer(CACHE_MANAGER);
        }
    };
}
 
Example 24
Source Project: spring-microservice-exam   Source File: GatewayExceptionConfig.java    License: MIT License 5 votes vote down vote up
/**
 * 自定义异常处理
 */
@Primary
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ObjectProvider<List<ViewResolver>> viewResolversProvider, ServerCodecConfigurer serverCodecConfigurer) {
    GatewayExceptionHandler gatewayExceptionHandler = new GatewayExceptionHandler();
    gatewayExceptionHandler.setViewResolvers(viewResolversProvider.getIfAvailable(Collections::emptyList));
    gatewayExceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters());
    gatewayExceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders());
    return gatewayExceptionHandler;
}
 
Example 25
/**
 * Create a new CommonAnnotationBeanPostProcessor,
 * with the init and destroy annotation types set to
 * {@link javax.annotation.PostConstruct} and {@link javax.annotation.PreDestroy},
 * respectively.
 */
public CommonAnnotationBeanPostProcessor() {
	setOrder(Ordered.LOWEST_PRECEDENCE - 3);
	setInitAnnotationType(PostConstruct.class);
	setDestroyAnnotationType(PreDestroy.class);
	ignoreResourceType("javax.xml.ws.WebServiceContext");
}
 
Example 26
Source Project: sophia_scaffolding   Source File: ErrorHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    JsonExceptionHandler exceptionHandler = new JsonExceptionHandler(
            errorAttributes,
            this.resourceProperties,
            this.serverProperties.getError(),
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example 27
Source Project: spring-analysis-note   Source File: EnableAsyncTests.java    License: MIT License 5 votes vote down vote up
@Test
public void orderAttributeIsPropagated() {
	AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
	ctx.register(OrderedAsyncConfig.class);
	ctx.refresh();

	AsyncAnnotationBeanPostProcessor bpp = ctx.getBean(AsyncAnnotationBeanPostProcessor.class);
	assertThat(bpp.getOrder(), is(Ordered.HIGHEST_PRECEDENCE));

	ctx.close();
}
 
Example 28
@Order(Ordered.HIGHEST_PRECEDENCE)
@Bean
public ComponentCustomizer<InfinispanComponent> customizer() {
    return new ComponentCustomizer<InfinispanComponent>() {
        @Override
        public void customize(InfinispanComponent component) {
            component.getConfiguration().setCacheContainer(CACHE_MANAGER);
        }
    };
}
 
Example 29
Source Project: open-capacity-platform   Source File: ErrorHandlerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
@Order(Ordered.HIGHEST_PRECEDENCE)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes) {
    JsonExceptionHandler exceptionHandler = new JsonExceptionHandler(
            errorAttributes, 
            this.resourceProperties,
            this.serverProperties.getError(), 
            this.applicationContext);
    exceptionHandler.setViewResolvers(this.viewResolvers);
    exceptionHandler.setMessageWriters(this.serverCodecConfigurer.getWriters());
    exceptionHandler.setMessageReaders(this.serverCodecConfigurer.getReaders());
    return exceptionHandler;
}
 
Example 30
Source Project: spring-analysis-note   Source File: MergedAnnotationsTests.java    License: MIT License 5 votes vote down vote up
@Test
public void getDefaultValueFromAnnotation() throws Exception {
	Method method = TransactionalStringGeneric.class.getMethod("something", Object.class);
	MergedAnnotation<Order> annotation = MergedAnnotations.from(method, SearchStrategy.EXHAUSTIVE)
			.get(Order.class);
	assertThat(annotation.getDefaultValue("value")).contains(Ordered.LOWEST_PRECEDENCE);
}