Search in sources :

Example 1 with Customer

use of org.springframework.data.mongodb.examples.custsvc.domain.Customer in project spring-data-document-examples by spring-projects.

the class CustomerRepositoryTests method testInsertOneEntity.

@Transactional
@Rollback(false)
@Test
public void testInsertOneEntity() {
    Customer c = new Customer();
    c.setFirstName("Sven");
    c.setLastName("Olafsen");
    SurveyInfo surveyInfo = new SurveyInfo();
    Map<String, String> qAndA = new HashMap<String, String>();
    qAndA.put("age", "22");
    qAndA.put("married", "Yes");
    qAndA.put("citizenship", "Norwegian");
    surveyInfo.setQuestionsAndAnswers(qAndA);
    c.setSurveyInfo(surveyInfo);
    customerRepository.save(c);
    Assert.assertNotNull(c.getId());
    idUsed = c.getId();
}
Also used : Customer(org.springframework.data.mongodb.examples.custsvc.domain.Customer) HashMap(java.util.HashMap) SurveyInfo(org.springframework.data.mongodb.examples.custsvc.domain.SurveyInfo) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with Customer

use of org.springframework.data.mongodb.examples.custsvc.domain.Customer in project spring-data-document-examples by spring-projects.

the class CustomerRepositoryTests method testDeleteOneEntity.

@Transactional
@Rollback(false)
@Test
public void testDeleteOneEntity() {
    Customer c = customerRepository.findOne(idUsed);
    customerRepository.delete(c);
}
Also used : Customer(org.springframework.data.mongodb.examples.custsvc.domain.Customer) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with Customer

use of org.springframework.data.mongodb.examples.custsvc.domain.Customer in project spring-data-document-examples by spring-projects.

the class CustomerRepositoryTests method testCheckOneEntityIsGone.

@Transactional
@Rollback(false)
@Test
public void testCheckOneEntityIsGone() {
    Customer c = customerRepository.findOne(idUsed);
    Assert.assertNull(c);
}
Also used : Customer(org.springframework.data.mongodb.examples.custsvc.domain.Customer) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with Customer

use of org.springframework.data.mongodb.examples.custsvc.domain.Customer in project spring-data-document-examples by spring-projects.

the class CustomerRepositoryTests method testUpdateOneEntity.

@Transactional
@Rollback(false)
@Test
public void testUpdateOneEntity() {
    Customer c = customerRepository.findOne(idUsed);
    Assert.assertNotNull(c);
    c.setLastName("Nilsson");
}
Also used : Customer(org.springframework.data.mongodb.examples.custsvc.domain.Customer) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with Customer

use of org.springframework.data.mongodb.examples.custsvc.domain.Customer in project spring-data-document-examples by spring-projects.

the class CustomerRepositoryTests method testCheckOneEntity.

@Transactional
@Rollback(false)
@Test
public void testCheckOneEntity() {
    Customer c = customerRepository.findOne(idUsed);
    Assert.assertNotNull(c);
    Assert.assertEquals("Nilsson", c.getLastName());
}
Also used : Customer(org.springframework.data.mongodb.examples.custsvc.domain.Customer) Test(org.junit.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Test (org.junit.Test)7 Customer (org.springframework.data.mongodb.examples.custsvc.domain.Customer)7 Transactional (org.springframework.transaction.annotation.Transactional)7 Rollback (org.springframework.test.annotation.Rollback)6 HashMap (java.util.HashMap)1 SurveyInfo (org.springframework.data.mongodb.examples.custsvc.domain.SurveyInfo)1