Search in sources :

Example 6 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 testInsertNewEntity.

@Transactional
@Test
public void testInsertNewEntity() {
    Customer c = new Customer();
    c.setFirstName("Sven");
    c.setLastName("Svensson");
    customerRepository.save(c);
    List<Customer> results = customerRepository.findAll();
    Assert.assertEquals(1, results.size());
}
Also used : Customer(org.springframework.data.mongodb.examples.custsvc.domain.Customer) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 7 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 testCheckOneEntityHasDocument.

@Transactional
@Rollback(false)
@Test
public void testCheckOneEntityHasDocument() {
    Customer c = customerRepository.findOne(idUsed);
    Assert.assertNotNull(c);
    Assert.assertNotNull(c.getSurveyInfo());
    Assert.assertNotNull(c.getSurveyInfo().getQuestionsAndAnswers());
    Assert.assertEquals("22", c.getSurveyInfo().getQuestionsAndAnswers().get("age"));
}
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