Polish
This commit is contained in:
parent
f36b051071
commit
5703fb1515
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -240,18 +240,22 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
|
||||||
for (RequestMappingHandlerAdapter handlerAdapter : this.handlerAdapters) {
|
for (RequestMappingHandlerAdapter handlerAdapter : this.handlerAdapters) {
|
||||||
for (HttpMessageConverter<?> messageConverter : handlerAdapter
|
for (HttpMessageConverter<?> messageConverter : handlerAdapter
|
||||||
.getMessageConverters()) {
|
.getMessageConverters()) {
|
||||||
if (messageConverter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
|
configureHttpMessageConverter(messageConverter);
|
||||||
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(
|
|
||||||
messageConverter.getSupportedMediaTypes());
|
|
||||||
supportedMediaTypes
|
|
||||||
.add(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON);
|
|
||||||
((AbstractHttpMessageConverter<?>) messageConverter)
|
|
||||||
.setSupportedMediaTypes(supportedMediaTypes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void configureHttpMessageConverter(
|
||||||
|
HttpMessageConverter<?> messageConverter) {
|
||||||
|
if (messageConverter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
|
||||||
|
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(
|
||||||
|
messageConverter.getSupportedMediaTypes());
|
||||||
|
supportedMediaTypes.add(ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON);
|
||||||
|
((AbstractHttpMessageConverter<?>) messageConverter)
|
||||||
|
.setSupportedMediaTypes(supportedMediaTypes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supports(MethodParameter returnType,
|
public boolean supports(MethodParameter returnType,
|
||||||
Class<? extends HttpMessageConverter<?>> converterType) {
|
Class<? extends HttpMessageConverter<?>> converterType) {
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias for {@link RequestMapping#value}.
|
* Alias for {@link RequestMapping#value}.
|
||||||
*
|
|
||||||
* @return the value
|
* @return the value
|
||||||
*/
|
*/
|
||||||
@AliasFor(annotation = RequestMapping.class)
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import org.springframework.http.MediaType;
|
||||||
* {@link MediaType MediaTypes} that can be consumed and produced by Actuator endpoints.
|
* {@link MediaType MediaTypes} that can be consumed and produced by Actuator endpoints.
|
||||||
*
|
*
|
||||||
* @author Andy Wilkinson
|
* @author Andy Wilkinson
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public final class ActuatorMediaTypes {
|
public final class ActuatorMediaTypes {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,6 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alias for {@link RequestMapping#value}.
|
* Alias for {@link RequestMapping#value}.
|
||||||
*
|
|
||||||
* @return the value
|
* @return the value
|
||||||
*/
|
*/
|
||||||
@AliasFor(annotation = RequestMapping.class)
|
@AliasFor(annotation = RequestMapping.class)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2015 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -17,9 +17,8 @@
|
||||||
package org.springframework.boot.autoconfigure.hateoas;
|
package org.springframework.boot.autoconfigure.hateoas;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
|
@ -63,31 +62,35 @@ public class HypermediaHttpMessageConverterConfiguration {
|
||||||
private volatile BeanFactory beanFactory;
|
private volatile BeanFactory beanFactory;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void customizedSupportedMediaTypes() {
|
public void configureHttpMessageConverters() {
|
||||||
if (this.beanFactory instanceof ListableBeanFactory) {
|
if (this.beanFactory instanceof ListableBeanFactory) {
|
||||||
Map<String, RequestMappingHandlerAdapter> handlerAdapters = ((ListableBeanFactory) this.beanFactory)
|
configureHttpMessageConverters(((ListableBeanFactory) this.beanFactory)
|
||||||
.getBeansOfType(RequestMappingHandlerAdapter.class);
|
.getBeansOfType(RequestMappingHandlerAdapter.class).values());
|
||||||
for (Entry<String, RequestMappingHandlerAdapter> entry : handlerAdapters
|
}
|
||||||
.entrySet()) {
|
}
|
||||||
RequestMappingHandlerAdapter handlerAdapter = entry.getValue();
|
|
||||||
for (HttpMessageConverter<?> converter : handlerAdapter
|
|
||||||
.getMessageConverters()) {
|
|
||||||
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
|
|
||||||
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(
|
|
||||||
converter.getSupportedMediaTypes());
|
|
||||||
if (!supportedMediaTypes
|
|
||||||
.contains(MediaType.APPLICATION_JSON)) {
|
|
||||||
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
|
|
||||||
}
|
|
||||||
((AbstractHttpMessageConverter<?>) converter)
|
|
||||||
.setSupportedMediaTypes(supportedMediaTypes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
private void configureHttpMessageConverters(
|
||||||
|
Collection<RequestMappingHandlerAdapter> handlerAdapters) {
|
||||||
|
for (RequestMappingHandlerAdapter handlerAdapter : handlerAdapters) {
|
||||||
|
for (HttpMessageConverter<?> messageConverter : handlerAdapter
|
||||||
|
.getMessageConverters()) {
|
||||||
|
configureHttpMessageConverter(messageConverter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void configureHttpMessageConverter(HttpMessageConverter<?> converter) {
|
||||||
|
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
|
||||||
|
List<MediaType> supportedMediaTypes = new ArrayList<MediaType>(
|
||||||
|
converter.getSupportedMediaTypes());
|
||||||
|
if (!supportedMediaTypes.contains(MediaType.APPLICATION_JSON)) {
|
||||||
|
supportedMediaTypes.add(MediaType.APPLICATION_JSON);
|
||||||
|
}
|
||||||
|
((AbstractHttpMessageConverter<?>) converter)
|
||||||
|
.setSupportedMediaTypes(supportedMediaTypes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||||
this.beanFactory = beanFactory;
|
this.beanFactory = beanFactory;
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||||
load();
|
load();
|
||||||
assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1);
|
assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1);
|
||||||
MongoClient client = this.context.getBean(MongoClient.class);
|
MongoClient client = this.context.getBean(MongoClient.class);
|
||||||
Integer mongoPort = Integer.valueOf(
|
Integer mongoPort = Integer
|
||||||
this.context.getEnvironment().getProperty("local.mongo.port"));
|
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
|
||||||
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,8 +92,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||||
load("spring.data.mongodb.port=0");
|
load("spring.data.mongodb.port=0");
|
||||||
assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1);
|
assertThat(this.context.getBeansOfType(MongoClient.class)).hasSize(1);
|
||||||
MongoClient client = this.context.getBean(MongoClient.class);
|
MongoClient client = this.context.getBean(MongoClient.class);
|
||||||
Integer mongoPort = Integer.valueOf(
|
Integer mongoPort = Integer
|
||||||
this.context.getEnvironment().getProperty("local.mongo.port"));
|
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
|
||||||
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -101,8 +101,8 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||||
public void randomlyAllocatedPortIsAvailableWhenCreatingMongoClient() {
|
public void randomlyAllocatedPortIsAvailableWhenCreatingMongoClient() {
|
||||||
load(MongoClientConfiguration.class);
|
load(MongoClientConfiguration.class);
|
||||||
MongoClient client = this.context.getBean(MongoClient.class);
|
MongoClient client = this.context.getBean(MongoClient.class);
|
||||||
Integer mongoPort = Integer.valueOf(
|
Integer mongoPort = Integer
|
||||||
this.context.getEnvironment().getProperty("local.mongo.port"));
|
.valueOf(this.context.getEnvironment().getProperty("local.mongo.port"));
|
||||||
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
assertThat(client.getAddress().getPort()).isEqualTo(mongoPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -187,8 +187,7 @@ public class EmbeddedMongoAutoConfigurationTests {
|
||||||
ctx.register(config);
|
ctx.register(config);
|
||||||
}
|
}
|
||||||
EnvironmentTestUtils.addEnvironment(ctx, environment);
|
EnvironmentTestUtils.addEnvironment(ctx, environment);
|
||||||
ctx.register(EmbeddedMongoAutoConfiguration.class,
|
ctx.register(EmbeddedMongoAutoConfiguration.class, MongoAutoConfiguration.class,
|
||||||
MongoAutoConfiguration.class,
|
|
||||||
PropertyPlaceholderAutoConfiguration.class);
|
PropertyPlaceholderAutoConfiguration.class);
|
||||||
ctx.refresh();
|
ctx.refresh();
|
||||||
this.context = ctx;
|
this.context = ctx;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2013 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||||
* tests. Most tests should consider using {@link DataMongoTest @DataMongoTest} rather
|
* tests. Most tests should consider using {@link DataMongoTest @DataMongoTest} rather
|
||||||
* than using this annotation directly.
|
* than using this annotation directly.
|
||||||
*
|
*
|
||||||
* @author Michael J. Simons
|
* @author Michael Simons
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
* @see DataMongoTest
|
* @see DataMongoTest
|
||||||
*/
|
*/
|
||||||
|
|
@ -40,4 +40,5 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||||
@Inherited
|
@Inherited
|
||||||
@ImportAutoConfiguration
|
@ImportAutoConfiguration
|
||||||
public @interface AutoConfigureDataMongo {
|
public @interface AutoConfigureDataMongo {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ import org.springframework.test.context.BootstrapWith;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)}
|
* Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)}
|
||||||
* for a typical MongoDB test. Can be used when a test focuses
|
* for a typical MongoDB test. Can be used when a test focuses <strong>only</strong> on
|
||||||
* <strong>only</strong> on MongoDB components.
|
* MongoDB components.
|
||||||
* <p>
|
* <p>
|
||||||
* Using this annotation will disable full auto-configuration and instead apply only
|
* Using this annotation will disable full auto-configuration and instead apply only
|
||||||
* configuration relevant to MongoDB tests.
|
* configuration relevant to MongoDB tests.
|
||||||
|
|
@ -44,7 +44,7 @@ import org.springframework.test.context.BootstrapWith;
|
||||||
* By default, tests annotated with {@code @DataMongoTest} will use an embedded in-memory
|
* By default, tests annotated with {@code @DataMongoTest} will use an embedded in-memory
|
||||||
* MongoDB process (if available).
|
* MongoDB process (if available).
|
||||||
*
|
*
|
||||||
* @author Michael J. Simons
|
* @author Michael Simons
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
|
|
@ -62,9 +62,8 @@ public @interface DataMongoTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if default filtering should be used with
|
* Determines if default filtering should be used with
|
||||||
* {@link SpringBootApplication @SpringBootApplication}. By default no beans
|
* {@link SpringBootApplication @SpringBootApplication}. By default no beans are
|
||||||
* are included.
|
* included.
|
||||||
*
|
|
||||||
* @see #includeFilters()
|
* @see #includeFilters()
|
||||||
* @see #excludeFilters()
|
* @see #excludeFilters()
|
||||||
* @return if default filters should be used
|
* @return if default filters should be used
|
||||||
|
|
@ -72,17 +71,15 @@ public @interface DataMongoTest {
|
||||||
boolean useDefaultFilters() default true;
|
boolean useDefaultFilters() default true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of include filters which can be used to add otherwise filtered
|
* A set of include filters which can be used to add otherwise filtered beans to the
|
||||||
* beans to the application context.
|
* application context.
|
||||||
*
|
|
||||||
* @return include filters to apply
|
* @return include filters to apply
|
||||||
*/
|
*/
|
||||||
Filter[] includeFilters() default {};
|
Filter[] includeFilters() default {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A set of exclude filters which can be used to filter beans that would
|
* A set of exclude filters which can be used to filter beans that would otherwise be
|
||||||
* otherwise be added to the application context.
|
* added to the application context.
|
||||||
*
|
|
||||||
* @return exclude filters to apply
|
* @return exclude filters to apply
|
||||||
*/
|
*/
|
||||||
Filter[] excludeFilters() default {};
|
Filter[] excludeFilters() default {};
|
||||||
|
|
@ -93,4 +90,5 @@ public @interface DataMongoTest {
|
||||||
*/
|
*/
|
||||||
@AliasFor(annotation = ImportAutoConfiguration.class, attribute = "exclude")
|
@AliasFor(annotation = ImportAutoConfiguration.class, attribute = "exclude")
|
||||||
Class<?>[] excludeAutoConfiguration() default {};
|
Class<?>[] excludeAutoConfiguration() default {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -30,7 +30,7 @@ import org.springframework.core.type.classreading.MetadataReaderFactory;
|
||||||
/**
|
/**
|
||||||
* {@link TypeExcludeFilter} for {@link DataMongoTest @DataMongoTest}.
|
* {@link TypeExcludeFilter} for {@link DataMongoTest @DataMongoTest}.
|
||||||
*
|
*
|
||||||
* @author Michael J. Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
class DataMongoTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
|
class DataMongoTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
|
||||||
|
|
||||||
|
|
@ -49,12 +49,12 @@ class DataMongoTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter
|
||||||
@Override
|
@Override
|
||||||
protected Filter[] getFilters(final FilterType type) {
|
protected Filter[] getFilters(final FilterType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case INCLUDE:
|
case INCLUDE:
|
||||||
return this.annotation.includeFilters();
|
return this.annotation.includeFilters();
|
||||||
case EXCLUDE:
|
case EXCLUDE:
|
||||||
return this.annotation.excludeFilters();
|
return this.annotation.excludeFilters();
|
||||||
default:
|
default:
|
||||||
throw new IllegalStateException("Unsupported type " + type);
|
throw new IllegalStateException("Unsupported type " + type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -32,7 +32,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* Sample test for {@link DataMongoTest @DataMongoTest}
|
* Sample test for {@link DataMongoTest @DataMongoTest}
|
||||||
*
|
*
|
||||||
* @author Michael J. Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DataMongoTest
|
@DataMongoTest
|
||||||
|
|
@ -54,10 +54,8 @@ public class DataMongoTestIntegrationTests {
|
||||||
public void testRepository() {
|
public void testRepository() {
|
||||||
ExampleDocument exampleDocument = new ExampleDocument();
|
ExampleDocument exampleDocument = new ExampleDocument();
|
||||||
exampleDocument.setText("Look, new @DataMongoTest!");
|
exampleDocument.setText("Look, new @DataMongoTest!");
|
||||||
|
|
||||||
exampleDocument = this.exampleRepository.save(exampleDocument);
|
exampleDocument = this.exampleRepository.save(exampleDocument);
|
||||||
assertThat(exampleDocument.getId()).isNotNull();
|
assertThat(exampleDocument.getId()).isNotNull();
|
||||||
|
|
||||||
assertThat(this.mongoTemplate.collectionExists("exampleDocuments")).isTrue();
|
assertThat(this.mongoTemplate.collectionExists("exampleDocuments")).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||||
/**
|
/**
|
||||||
* Integration test with custom include filter for {@link DataMongoTest}.
|
* Integration test with custom include filter for {@link DataMongoTest}.
|
||||||
*
|
*
|
||||||
* @author Michael J. Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@DataMongoTest(includeFilters = @Filter(Service.class))
|
@DataMongoTest(includeFilters = @Filter(Service.class))
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,7 +21,7 @@ import org.springframework.data.mongodb.core.mapping.Document;
|
||||||
/**
|
/**
|
||||||
* Example document used with {@link DataMongoTest} tests.
|
* Example document used with {@link DataMongoTest} tests.
|
||||||
*
|
*
|
||||||
* @author Michael J. Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
@Document(collection = "exampleDocuments")
|
@Document(collection = "exampleDocuments")
|
||||||
public class ExampleDocument {
|
public class ExampleDocument {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,7 +21,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
/**
|
/**
|
||||||
* Example {@link SpringBootApplication} used with {@link DataMongoTest} tests.
|
* Example {@link SpringBootApplication} used with {@link DataMongoTest} tests.
|
||||||
*
|
*
|
||||||
* @author Michael J. Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class ExampleMongoApplication {
|
public class ExampleMongoApplication {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -21,7 +21,8 @@ import org.springframework.data.mongodb.repository.MongoRepository;
|
||||||
/**
|
/**
|
||||||
* Example repository used with {@link DataMongoTest} tests.
|
* Example repository used with {@link DataMongoTest} tests.
|
||||||
*
|
*
|
||||||
* @author Michael J. Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
public interface ExampleRepository extends MongoRepository<ExampleDocument, String> {
|
public interface ExampleRepository extends MongoRepository<ExampleDocument, String> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,11 @@ import org.springframework.stereotype.Service;
|
||||||
/**
|
/**
|
||||||
* Example service used with {@link DataMongoTest} tests.
|
* Example service used with {@link DataMongoTest} tests.
|
||||||
*
|
*
|
||||||
* @author Michael J. Simons
|
* @author Michael Simons
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ExampleService {
|
public class ExampleService {
|
||||||
|
|
||||||
private final MongoTemplate mongoTemplate;
|
private final MongoTemplate mongoTemplate;
|
||||||
|
|
||||||
public ExampleService(MongoTemplate mongoTemplate) {
|
public ExampleService(MongoTemplate mongoTemplate) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2012-2016 the original author or authors.
|
* Copyright 2012-2017 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue