#524 - Polishing.

Closes #525.
This commit is contained in:
Christoph Strobl
2019-10-01 13:26:33 +02:00
parent e39a10d808
commit acc26c46b5
4 changed files with 21 additions and 10 deletions

View File

@@ -0,0 +1,9 @@
# Spring Data MongoDB - Example
This project contains examples for:
* Derived finder and geo spatial queries using a `Repository` interface.
* `EntityCallback` API usage for before convert/save interaction.
* Result projections for DTOs and interface types.
* Query metadata.

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -24,16 +24,19 @@ import org.springframework.data.mongodb.core.mapping.event.BeforeConvertCallback
import com.mongodb.MongoClient;
/**
* Test configuration to connect to a MongoDB named "test" and using a {@link MongoClient}. Also enables Spring Data
* repositories for MongoDB.
* Test configuration to connect to a MongoDB named "test" using a {@link MongoClient}. <br />
* Also enables Spring Data repositories for MongoDB.
*
* @author Mark Paluch
* @author Christoph Strobl
*/
@SpringBootApplication
class ApplicationConfiguration {
/**
* Callback to update {@link ImmutablePerson}.
* Register the {@link BeforeConvertCallback} used to update an {@link ImmutablePerson} before handing over the newly
* created instance to the actual mapping layer performing the conversion into the store native
* {@link org.bson.Document} representation.
*
* @return a {@link BeforeConvertCallback} for {@link ImmutablePerson}.
*/
@@ -44,6 +47,7 @@ class ApplicationConfiguration {
int randomNumber = ThreadLocalRandom.current().nextInt(1, 100);
// withRandomNumber is a so called wither method returning a new instance of the entity with a new value assigned
return immutablePerson.withRandomNumber(randomNumber);
};
}

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -32,7 +32,6 @@ import org.bson.types.ObjectId;
public class ImmutablePerson {
private final ObjectId id;
private final int randomNumber;
public ImmutablePerson() {

View File

@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -20,7 +20,6 @@ import static org.assertj.core.api.Assertions.*;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.mongodb.core.MongoOperations;
@@ -30,6 +29,7 @@ import org.springframework.test.context.junit4.SpringRunner;
* Integration test for {@link ImmutablePerson} showing features around immutable object support.
*
* @author Mark Paluch
* @author Christoph Strobl
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@@ -39,8 +39,7 @@ public class ImmutableEntityIntegrationTest {
@Before
public void setUp() {
operations.remove(ImmutablePerson.class);
operations.dropCollection(ImmutablePerson.class);
}
/**