clean and upgrade
This commit is contained in:
parent
9c544345b3
commit
86c9b89ed9
|
@ -31,16 +31,16 @@
|
|||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-reactivestreams</artifactId>
|
||||
<version>1.9.2</version>
|
||||
<version>${mongodb-reactivestreams.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
<artifactId>reactor-test</artifactId>
|
||||
<version>3.2.0.RELEASE</version>
|
||||
<version>${projectreactor.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
|
@ -106,8 +106,9 @@
|
|||
<org.springframework.data.version>2.1.0.RELEASE</org.springframework.data.version>
|
||||
<querydsl.version>4.1.4</querydsl.version>
|
||||
<mysema.maven.version>1.1.3</mysema.maven.version>
|
||||
<spring.version>5.1.0.RELEASE</spring.version>
|
||||
|
||||
<spring.version>5.1.0.RELEASE</spring.version>
|
||||
<mongodb-reactivestreams.version>1.9.2</mongodb-reactivestreams.version>
|
||||
<projectreactor.version>3.2.0.RELEASE</projectreactor.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.springframework.core.convert.converter.Converter;
|
|||
import org.springframework.data.mongodb.MongoDbFactory;
|
||||
import org.springframework.data.mongodb.MongoTransactionManager;
|
||||
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
|
||||
import org.springframework.data.mongodb.core.convert.CustomConversions;
|
||||
import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
|
||||
import org.springframework.data.mongodb.gridfs.GridFsTemplate;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
|
@ -50,9 +50,9 @@ public class MongoConfig extends AbstractMongoConfiguration {
|
|||
}
|
||||
|
||||
@Override
|
||||
public CustomConversions customConversions() {
|
||||
public MongoCustomConversions customConversions() {
|
||||
converters.add(new UserWriterConverter());
|
||||
return new CustomConversions(converters);
|
||||
return new MongoCustomConversions(converters);
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
|
|
@ -40,11 +40,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|||
|
||||
import com.baeldung.aggregation.model.StatePopulation;
|
||||
import com.baeldung.config.MongoConfig;
|
||||
import com.mongodb.DB;
|
||||
import com.mongodb.DBCollection;
|
||||
import com.mongodb.DBObject;
|
||||
import com.mongodb.MongoClient;
|
||||
import com.mongodb.util.JSON;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
|
@ -58,23 +56,22 @@ public class ZipsAggregationLiveTest {
|
|||
@BeforeClass
|
||||
public static void setupTests() throws Exception {
|
||||
client = new MongoClient();
|
||||
DB testDB = client.getDB("test");
|
||||
DBCollection zipsCollection = testDB.getCollection("zips");
|
||||
MongoDatabase testDB = client.getDatabase("test");
|
||||
MongoCollection<Document> zipsCollection = testDB.getCollection("zips");
|
||||
zipsCollection.drop();
|
||||
|
||||
InputStream zipsJsonStream = ZipsAggregationLiveTest.class.getResourceAsStream("/zips.json");
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(zipsJsonStream));
|
||||
reader.lines()
|
||||
.forEach(line -> zipsCollection.insert((DBObject) JSON.parse(line)));
|
||||
.forEach(line -> zipsCollection.insertOne(Document.parse(line)));
|
||||
reader.close();
|
||||
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void tearDown() throws Exception {
|
||||
client = new MongoClient();
|
||||
DB testDB = client.getDB("test");
|
||||
DBCollection zipsCollection = testDB.getCollection("zips");
|
||||
MongoDatabase testDB = client.getDatabase("test");
|
||||
MongoCollection<Document> zipsCollection = testDB.getCollection("zips");
|
||||
zipsCollection.drop();
|
||||
client.close();
|
||||
}
|
||||
|
|
|
@ -205,10 +205,9 @@ public class GridFSLiveTest {
|
|||
DBObject metaData = new BasicDBObject();
|
||||
metaData.put("user", "alex");
|
||||
InputStream inputStream = null;
|
||||
String id = "";
|
||||
try {
|
||||
inputStream = new FileInputStream("src/main/resources/test.png");
|
||||
id = gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).toString();
|
||||
gridFsTemplate.store(inputStream, "test.png", "image/png", metaData).toString();
|
||||
} catch (FileNotFoundException ex) {
|
||||
logger.error("File not found", ex);
|
||||
} finally {
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.baeldung.mongotemplate;
|
||||
|
||||
import com.baeldung.config.MongoConfig;
|
||||
import com.baeldung.model.EmailAddress;
|
||||
import com.baeldung.model.User;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -17,11 +20,9 @@ import org.springframework.data.mongodb.core.query.Query;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import com.baeldung.config.MongoConfig;
|
||||
import com.baeldung.model.EmailAddress;
|
||||
import com.baeldung.model.User;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
|
@ -152,7 +153,7 @@ public class DocumentQueryLiveTest {
|
|||
user.setAge(35);
|
||||
mongoTemplate.insert(user);
|
||||
|
||||
final Pageable pageableRequest = new PageRequest(0, 2);
|
||||
final Pageable pageableRequest = PageRequest.of(0, 2);
|
||||
Query query = new Query();
|
||||
query.with(pageableRequest);
|
||||
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.baeldung.mongotemplate;
|
||||
|
||||
import com.baeldung.config.MongoConfig;
|
||||
import com.baeldung.model.EmailAddress;
|
||||
import com.baeldung.model.User;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -20,11 +23,9 @@ import org.springframework.data.mongodb.core.query.Query;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import com.baeldung.config.MongoConfig;
|
||||
import com.baeldung.model.EmailAddress;
|
||||
import com.baeldung.model.User;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = MongoConfig.class)
|
||||
|
@ -104,7 +105,7 @@ public class MongoTemplateQueryLiveTest {
|
|||
user.setAge(35);
|
||||
mongoTemplate.insert(user);
|
||||
|
||||
final Pageable pageableRequest = new PageRequest(0, 2);
|
||||
final Pageable pageableRequest = PageRequest.of(0, 2);
|
||||
Query query = new Query();
|
||||
query.with(pageableRequest);
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ public class UserRepositoryLiveTest {
|
|||
user.setName("Adam");
|
||||
mongoOps.insert(user);
|
||||
|
||||
final Pageable pageableRequest = new PageRequest(0, 1);
|
||||
final Pageable pageableRequest = PageRequest.of(0, 1);
|
||||
|
||||
final Page<User> page = userRepository.findAll(pageableRequest);
|
||||
List<User> users = page.getContent();
|
||||
|
|
Loading…
Reference in New Issue