Formatting cleanup

This commit is contained in:
alex-semenyuk 2015-08-09 19:13:51 +02:00
parent 759298a2bc
commit 02ba4a5605
5 changed files with 66 additions and 69 deletions

View File

@ -25,6 +25,6 @@ public interface UserRepository extends MongoRepository<User, String>, QueryDslP
List<User> findByAgeBetween(int ageGT, int ageLT);
List<User> findByNameStartingWith(String regexp);
List<User> findByNameEndingWith(String regexp);
}

View File

@ -37,7 +37,7 @@ public class DocumentQueryIntegrationTest {
public void tearDown() {
mongoTemplate.dropCollection(User.class);
}
@Test
public void givenUsersExist_whenFindingUsersByName_thenUsersAreFound() {
User user = new User();
@ -103,7 +103,7 @@ public class DocumentQueryIntegrationTest {
List<User> users = mongoTemplate.find(query, User.class);
assertThat(users.size(), is(2));
}
@Test
public void givenUsersExist_whenFindingUserWithNameEndWithC_thenUsersAreFound() {
User user = new User();

View File

@ -7,7 +7,6 @@ import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoOperations;
public class BaseQueryIntegrationTest {
@Autowired

View File

@ -18,7 +18,7 @@ import com.mysema.query.types.Predicate;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
public class DSLQueryIntegrationTest extends BaseQueryIntegrationTest {
@Test
public void givenUsersExist_whenFindingUsersByName_thenUserAreFound() {
User user = new User();
@ -37,7 +37,7 @@ public class DSLQueryIntegrationTest extends BaseQueryIntegrationTest {
assertThat(users.size(), is(1));
}
@Test
public void givenUsersExist_whenFindingUsersWithAgeCreaterThanAndLessThan_thenUsersAreFound() {
User user = new User();
@ -62,7 +62,7 @@ public class DSLQueryIntegrationTest extends BaseQueryIntegrationTest {
assertThat(users.size(), is(1));
}
@Test
public void givenUsersExist_whenFindingUserWithNameStartWithA_thenUsersAreFound() {
User user = new User();
@ -86,7 +86,7 @@ public class DSLQueryIntegrationTest extends BaseQueryIntegrationTest {
List<User> users = (List<User>) userRepository.findAll(predicate);
assertThat(users.size(), is(2));
}
@Test
public void givenUsersExist_whenFindingUserWithNameEndWithC_thenUsersAreFound() {
User user = new User();
@ -107,8 +107,7 @@ public class DSLQueryIntegrationTest extends BaseQueryIntegrationTest {
QUser qUser = new QUser("user");
Predicate predicate = qUser.name.endsWith("c");
List<User> users = (List<User>) userRepository.findAll(predicate);
assertThat(users.size(), is(1));
}
}

View File

@ -15,8 +15,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
public class JSONQueryIntegrationTest extends BaseQueryIntegrationTest {
@Test
@Test
public void givenUsersExist_whenFindingUsersByName_thenUsersAreFound() {
User user = new User();
user.setName("Eric");
@ -30,70 +30,69 @@ public class JSONQueryIntegrationTest extends BaseQueryIntegrationTest {
List<User> users = userRepository.findUsersByName("Eric");
assertThat(users.size(), is(1));
}
@Test
public void givenUsersExist_whenFindingUsersWithAgeCreaterThanAndLessThan_thenUsersAreFound() {
User user = new User();
user.setAge(20);
user.setName("Jon");
mongoOps.insert(user);
user = new User();
user.setAge(50);
user.setName("Jon");
mongoOps.insert(user);
@Test
public void givenUsersExist_whenFindingUsersWithAgeCreaterThanAndLessThan_thenUsersAreFound() {
User user = new User();
user.setAge(20);
user.setName("Jon");
mongoOps.insert(user);
user = new User();
user.setAge(33);
user.setName("Jim");
mongoOps.insert(user);
user = new User();
user.setAge(50);
user.setName("Jon");
mongoOps.insert(user);
List<User> users = userRepository.findUsersByAgeBetween(26, 40);
assertThat(users.size(), is(1));
}
@Test
public void givenUsersExist_whenFindingUserWithNameStartWithA_thenUsersAreFound() {
User user = new User();
user.setName("Eric");
user.setAge(45);
mongoOps.insert(user);
user = new User();
user.setAge(33);
user.setName("Jim");
mongoOps.insert(user);
user = new User();
user.setName("Antony");
user.setAge(33);
mongoOps.insert(user);
List<User> users = userRepository.findUsersByAgeBetween(26, 40);
assertThat(users.size(), is(1));
}
user = new User();
user.setName("Alice");
user.setAge(35);
mongoOps.insert(user);
@Test
public void givenUsersExist_whenFindingUserWithNameStartWithA_thenUsersAreFound() {
User user = new User();
user.setName("Eric");
user.setAge(45);
mongoOps.insert(user);
List<User> users = userRepository.findUsersByRegexpName("^A");
assertThat(users.size(), is(2));
}
@Test
public void givenUsersExist_whenFindingUserWithNameEndWithC_thenUsersAreFound() {
User user = new User();
user.setName("Eric");
user.setAge(45);
mongoOps.insert(user);
user = new User();
user.setName("Antony");
user.setAge(33);
mongoOps.insert(user);
user = new User();
user.setName("Antony");
user.setAge(33);
mongoOps.insert(user);
user = new User();
user.setName("Alice");
user.setAge(35);
mongoOps.insert(user);
user = new User();
user.setName("Alice");
user.setAge(35);
mongoOps.insert(user);
List<User> users = userRepository.findUsersByRegexpName("^A");
List<User> users = userRepository.findUsersByRegexpName("c$");
assertThat(users.size(), is(1));
}
assertThat(users.size(), is(2));
}
@Test
public void givenUsersExist_whenFindingUserWithNameEndWithC_thenUsersAreFound() {
User user = new User();
user.setName("Eric");
user.setAge(45);
mongoOps.insert(user);
user = new User();
user.setName("Antony");
user.setAge(33);
mongoOps.insert(user);
user = new User();
user.setName("Alice");
user.setAge(35);
mongoOps.insert(user);
List<User> users = userRepository.findUsersByRegexpName("c$");
assertThat(users.size(), is(1));
}
}