Fix formatting

This commit is contained in:
coach88 2015-07-31 10:37:58 +03:00
parent 2e54ddc841
commit a0a9ef1b2c
3 changed files with 13 additions and 17 deletions

View File

@ -1,11 +1,8 @@
package org.baeldung.repository; package org.baeldung.repository;
import org.springframework.data.mongodb.repository.MongoRepository; import org.springframework.data.mongodb.repository.MongoRepository;
import org.springframework.stereotype.Repository;
import org.baeldung.model.User; import org.baeldung.model.User;
public interface UserRepository extends MongoRepository<User, String> { public interface UserRepository extends MongoRepository<User, String> {
} }

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p" xmlns:p="http://www.springframework.org/schema/p" xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation=" xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
@ -21,7 +20,7 @@
</bean> </bean>
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/> <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<mongo:repositories base-package="org.baeldung.repository" mongo-template-ref="mongoTemplate" /> <mongo:repositories base-package="org.baeldung.repository" mongo-template-ref="mongoTemplate"/>
</beans> </beans>

View File

@ -25,7 +25,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MongoConfig.class) @ContextConfiguration(classes = MongoConfig.class)
public class UserRepositoryIntegrationTest { public class UserRepositoryIntegrationTest {
@Autowired @Autowired
private UserRepository userRepository; private UserRepository userRepository;
@ -76,7 +76,7 @@ public class UserRepositoryIntegrationTest {
assertThat(mongoOps.find(Query.query(Criteria.where("name").is("Benn")), User.class).size(), is(0)); assertThat(mongoOps.find(Query.query(Criteria.where("name").is("Benn")), User.class).size(), is(0));
} }
@Test @Test
public void testFindOne() { public void testFindOne() {
User user = new User(); User user = new User();
@ -88,7 +88,7 @@ public class UserRepositoryIntegrationTest {
assertThat(user.getName(), is(foundUser.getName())); assertThat(user.getName(), is(foundUser.getName()));
} }
@Test @Test
public void testExists() { public void testExists() {
User user = new User(); User user = new User();
@ -100,36 +100,36 @@ public class UserRepositoryIntegrationTest {
assertThat(isExists, is(true)); assertThat(isExists, is(true));
} }
@Test @Test
public void testFindAllWithSort() { public void testFindAllWithSort() {
User user = new User(); User user = new User();
user.setName("Brendan"); user.setName("Brendan");
mongoOps.insert(user); mongoOps.insert(user);
user = new User(); user = new User();
user.setName("Adam"); user.setName("Adam");
mongoOps.insert(user); mongoOps.insert(user);
List<User> users = userRepository.findAll(new Sort(Sort.Direction.ASC,"name")); List<User> users = userRepository.findAll(new Sort(Sort.Direction.ASC, "name"));
assertThat(users.size(), is(2)); assertThat(users.size(), is(2));
assertThat(users.get(0).getName(), is("Adam")); assertThat(users.get(0).getName(), is("Adam"));
assertThat(users.get(1).getName(), is("Brendan")); assertThat(users.get(1).getName(), is("Brendan"));
} }
@Test @Test
public void testFindAllWithPageable() { public void testFindAllWithPageable() {
User user = new User(); User user = new User();
user.setName("Brendan"); user.setName("Brendan");
mongoOps.insert(user); mongoOps.insert(user);
user = new User(); user = new User();
user.setName("Adam"); user.setName("Adam");
mongoOps.insert(user); mongoOps.insert(user);
Pageable pageableRequest = new PageRequest(0, 2); Pageable pageableRequest = new PageRequest(0, 2);
Page<User> users = userRepository.findAll(pageableRequest); Page<User> users = userRepository.findAll(pageableRequest);
assertThat(users.getTotalPages(), is(1)); assertThat(users.getTotalPages(), is(1));