Search in sources :

Example 1 with SurveyInfo

use of org.springframework.data.mongodb.examples.custsvc.domain.SurveyInfo 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)

Aggregations

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