Delete collection for each IT test. (#329)
Signed-off-by: Pan Li <panli@microsoft.com>
This commit is contained in:
Родитель
b744cc9378
Коммит
9aea95a0cb
|
@ -7,9 +7,11 @@ package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
|||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.common.TestConstants;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.common.TestUtils;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Address;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.AddressRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -17,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -36,12 +39,23 @@ public class AddressRepositoryIT {
|
|||
private static final Address TEST_ADDRESS4_PARTITION3 = new Address(
|
||||
TestConstants.POSTAL_CODE, TestConstants.STREET_2, TestConstants.CITY_1);
|
||||
|
||||
private final DocumentDbEntityInformation<Address, String> entityInformation
|
||||
= new DocumentDbEntityInformation<>(Address.class);
|
||||
|
||||
@Autowired
|
||||
AddressRepository repository;
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
repository.save(TEST_ADDRESS1_PARTITION1);
|
||||
|
|
|
@ -6,9 +6,11 @@
|
|||
package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
||||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.common.TestUtils;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Contact;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.ContactRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.ContactRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -19,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -31,9 +34,20 @@ public class ContactRepositoryIT {
|
|||
|
||||
private static final Contact TEST_CONTACT = new Contact("testId", "faketitle");
|
||||
|
||||
private final DocumentDbEntityInformation<Contact, String> entityInformation =
|
||||
new DocumentDbEntityInformation<>(Contact.class);
|
||||
|
||||
@Autowired
|
||||
ContactRepository repository;
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
repository.save(TEST_CONTACT);
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
*/
|
||||
package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
||||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Customer;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.CustomerRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import lombok.NonNull;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -18,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -48,9 +51,20 @@ public class CustomerRepositoryIT {
|
|||
private static final Customer CUSTOMER_1 = new Customer(CUSTOMER_ID_1, CUSTOMER_LEVEL_1, USER_1);
|
||||
private static final Customer CUSTOMER_2 = new Customer(CUSTOMER_ID_2, CUSTOMER_LEVEL_1, USER_2);
|
||||
|
||||
private final DocumentDbEntityInformation<Customer, String> entityInformation =
|
||||
new DocumentDbEntityInformation<>(Customer.class);
|
||||
|
||||
@Autowired
|
||||
private CustomerRepository repository;
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.repository.saveAll(Arrays.asList(CUSTOMER_0, CUSTOMER_1, CUSTOMER_2));
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
*/
|
||||
package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
||||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.IntegerIdDomain;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.IntegerIdDomainRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.IntegerIdDomainRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
@ -20,8 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.Optional;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
|
@ -32,9 +32,20 @@ public class IntegerIdDomainRepositoryIT {
|
|||
private static final String NAME = "panli";
|
||||
private static final IntegerIdDomain DOMAIN = new IntegerIdDomain(ID, NAME);
|
||||
|
||||
private final DocumentDbEntityInformation<IntegerIdDomain, Integer> entityInformation =
|
||||
new DocumentDbEntityInformation<>(IntegerIdDomain.class);
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@Autowired
|
||||
private IntegerIdDomainRepository repository;
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.repository.save(DOMAIN);
|
||||
|
|
|
@ -7,17 +7,20 @@ package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
|||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.common.TestConstants;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.common.TestUtils;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Importance;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Memo;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.exception.DocumentDBAccessException;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.MemoRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
|
@ -42,6 +45,12 @@ public class MemoRepositoryIT {
|
|||
private static Memo testMemo2;
|
||||
private static Memo testMemo3;
|
||||
|
||||
private final DocumentDbEntityInformation<Memo, String> entityInformation =
|
||||
new DocumentDbEntityInformation<>(Memo.class);
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@Autowired
|
||||
MemoRepository repository;
|
||||
|
||||
|
@ -57,6 +66,11 @@ public class MemoRepositoryIT {
|
|||
testMemo3 = new Memo(TestConstants.ID_3, TestConstants.NEW_MESSAGE, memoDateAfter, Importance.LOW);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
repository.saveAll(Arrays.asList(testMemo1, testMemo2, testMemo3));
|
||||
|
|
|
@ -7,10 +7,12 @@ package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
|||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.common.TestConstants;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.common.TestUtils;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.query.DocumentDbPageRequest;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Address;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.PageableAddressRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -20,6 +22,7 @@ import org.springframework.data.domain.Page;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -41,6 +44,12 @@ public class PageableAddressRepositoryIT {
|
|||
private static final Address TEST_ADDRESS4_PARTITION3 = new Address(
|
||||
TestConstants.POSTAL_CODE, TestConstants.STREET_1, TestConstants.CITY_1);
|
||||
|
||||
private final DocumentDbEntityInformation<Address, String> entityInformation =
|
||||
new DocumentDbEntityInformation<>(Address.class);
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@Autowired
|
||||
private PageableAddressRepository repository;
|
||||
|
||||
|
@ -52,6 +61,11 @@ public class PageableAddressRepositoryIT {
|
|||
repository.save(TEST_ADDRESS4_PARTITION3);
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@After
|
||||
public void cleanup() {
|
||||
repository.deleteAll();
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
*/
|
||||
package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
||||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Project;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.ProjectRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -18,6 +20,7 @@ import org.springframework.lang.NonNull;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -67,9 +70,20 @@ public class ProjectRepositoryIT {
|
|||
|
||||
private static final List<Project> PROJECTS = Arrays.asList(PROJECT_0, PROJECT_1, PROJECT_2, PROJECT_3, PROJECT_4);
|
||||
|
||||
private final DocumentDbEntityInformation<Project, String> entityInformation =
|
||||
new DocumentDbEntityInformation<>(Project.class);
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@Autowired
|
||||
private ProjectRepository repository;
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.repository.saveAll(PROJECTS);
|
||||
|
|
|
@ -5,11 +5,13 @@
|
|||
*/
|
||||
package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
||||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.query.DocumentDbPageRequest;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Project;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.exception.DocumentDBAccessException;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.ProjectRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.RunWith;
|
||||
|
@ -20,6 +22,7 @@ import org.springframework.data.domain.Sort;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
@ -68,9 +71,20 @@ public class ProjectRepositorySortIT {
|
|||
|
||||
private static final List<Project> PROJECTS = Arrays.asList(PROJECT_4, PROJECT_3, PROJECT_2, PROJECT_1, PROJECT_0);
|
||||
|
||||
private final DocumentDbEntityInformation<Project, String> entityInformation =
|
||||
new DocumentDbEntityInformation<>(Project.class);
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@Autowired
|
||||
private ProjectRepository repository;
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.repository.saveAll(PROJECTS);
|
||||
|
|
|
@ -5,11 +5,13 @@
|
|||
*/
|
||||
package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
||||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Question;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.exception.DocumentDBAccessException;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.ProjectRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.QuestionRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
@ -20,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
@ -34,12 +37,23 @@ public class QuestionRepositoryIT {
|
|||
|
||||
private static final Question QUESTION = new Question(QUESTION_ID, QUESTION_URL);
|
||||
|
||||
private final DocumentDbEntityInformation<Question, String> entityInformation =
|
||||
new DocumentDbEntityInformation<>(Question.class);
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@Autowired
|
||||
private QuestionRepository repository;
|
||||
|
||||
@Autowired
|
||||
private ProjectRepository projectRepository;
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.repository.save(QUESTION);
|
||||
|
|
|
@ -5,11 +5,13 @@
|
|||
*/
|
||||
package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
||||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.query.DocumentDbPageRequest;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.IntegerIdDomain;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.exception.DocumentDBAccessException;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.IntegerIdDomainRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -17,6 +19,7 @@ import org.springframework.data.domain.Sort;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.Collections;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
|
@ -28,6 +31,17 @@ public class RoleRepositoryCollectionIT {
|
|||
@Autowired
|
||||
private IntegerIdDomainRepository repository;
|
||||
|
||||
private final DocumentDbEntityInformation<IntegerIdDomain, Integer> entityInformation =
|
||||
new DocumentDbEntityInformation<>(IntegerIdDomain.class);
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicQuery() {
|
||||
this.repository.save(DOMAIN);
|
||||
|
|
|
@ -6,9 +6,11 @@
|
|||
package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
||||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.common.TestUtils;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.inheritance.Square;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.SquareRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.SquareRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -17,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -25,12 +28,23 @@ import static org.assertj.core.api.Assertions.assertThat;
|
|||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = TestRepositoryConfig.class)
|
||||
public class SquareRepositoryIT {
|
||||
@Autowired
|
||||
SquareRepository repository;
|
||||
|
||||
private Square square1 = new Square("id_1", 1, 1);
|
||||
private Square square2 = new Square("id_2", 2, 4);
|
||||
|
||||
private final DocumentDbEntityInformation<Square, String> entityInformation =
|
||||
new DocumentDbEntityInformation<>(Square.class);
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@Autowired
|
||||
private SquareRepository repository;
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
repository.save(square1);
|
||||
|
@ -43,7 +57,7 @@ public class SquareRepositoryIT {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testFindAll() {
|
||||
public void testFindAll() {
|
||||
final List<Square> result = TestUtils.toList(repository.findAll());
|
||||
|
||||
assertThat(result.size()).isEqualTo(2);
|
||||
|
|
|
@ -5,9 +5,11 @@
|
|||
*/
|
||||
package com.microsoft.azure.spring.data.cosmosdb.repository.integration;
|
||||
|
||||
import com.microsoft.azure.spring.data.cosmosdb.core.DocumentDbTemplate;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.domain.Student;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.TestRepositoryConfig;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.repository.StudentRepository;
|
||||
import com.microsoft.azure.spring.data.cosmosdb.repository.support.DocumentDbEntityInformation;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
|
@ -16,10 +18,14 @@ import org.junit.runner.RunWith;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import javax.annotation.PreDestroy;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(classes = TestRepositoryConfig.class)
|
||||
|
@ -47,9 +53,20 @@ public class StudentRepositoryIT {
|
|||
private static final Student STUDENT_3 = new Student(ID_3, FIRST_NAME_3, LAST_NAME_3);
|
||||
private static final List<Student> PEOPLE = Arrays.asList(STUDENT_0, STUDENT_1, STUDENT_2, STUDENT_3);
|
||||
|
||||
private final DocumentDbEntityInformation<Student, String> entityInformation =
|
||||
new DocumentDbEntityInformation<>(Student.class);
|
||||
|
||||
@Autowired
|
||||
private DocumentDbTemplate template;
|
||||
|
||||
@Autowired
|
||||
private StudentRepository repository;
|
||||
|
||||
@PreDestroy
|
||||
public void cleanUpCollection() {
|
||||
template.deleteCollection(entityInformation.getCollectionName());
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
this.repository.saveAll(PEOPLE);
|
||||
|
|
Загрузка…
Ссылка в новой задаче