|
|
|
@ -16,9 +16,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.data.document.mongodb.mapping; |
|
|
|
package org.springframework.data.document.mongodb.mapping; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.Rule; |
|
|
|
|
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.rules.ExpectedException; |
|
|
|
|
|
|
|
import org.junit.runner.RunWith; |
|
|
|
import org.junit.runner.RunWith; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.data.document.mongodb.MongoTemplate; |
|
|
|
import org.springframework.data.document.mongodb.MongoTemplate; |
|
|
|
@ -50,9 +48,6 @@ public class MappingTests { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
BasicMappingContext mappingContext; |
|
|
|
BasicMappingContext mappingContext; |
|
|
|
|
|
|
|
|
|
|
|
@Rule |
|
|
|
|
|
|
|
public ExpectedException thrown = ExpectedException.none(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void setUp() { |
|
|
|
public void setUp() { |
|
|
|
template.dropCollection("person"); |
|
|
|
template.dropCollection("person"); |
|
|
|
@ -100,14 +95,12 @@ public class MappingTests { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@SuppressWarnings({"unchecked"}) |
|
|
|
@SuppressWarnings({"unchecked"}) |
|
|
|
public void testWriteEntity() { |
|
|
|
public void testWriteEntity() { |
|
|
|
Person p = new Person(123456789, "John", "Doe", 37); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Address addr = new Address(); |
|
|
|
Address addr = new Address(); |
|
|
|
addr.setLines(new String[]{"1234 W. 1st Street", "Apt. 12"}); |
|
|
|
addr.setLines(new String[]{"1234 W. 1st Street", "Apt. 12"}); |
|
|
|
addr.setCity("Anytown"); |
|
|
|
addr.setCity("Anytown"); |
|
|
|
addr.setPostalCode(12345); |
|
|
|
addr.setPostalCode(12345); |
|
|
|
addr.setCountry("USA"); |
|
|
|
addr.setCountry("USA"); |
|
|
|
p.setAddress(addr); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Account acct = new Account(); |
|
|
|
Account acct = new Account(); |
|
|
|
acct.setBalance(1000.00f); |
|
|
|
acct.setBalance(1000.00f); |
|
|
|
@ -115,8 +108,9 @@ public class MappingTests { |
|
|
|
|
|
|
|
|
|
|
|
List<Account> accounts = new ArrayList<Account>(); |
|
|
|
List<Account> accounts = new ArrayList<Account>(); |
|
|
|
accounts.add(acct); |
|
|
|
accounts.add(acct); |
|
|
|
p.setAccounts(accounts); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Person p = new Person(123456789, "John", "Doe", 37, addr); |
|
|
|
|
|
|
|
p.setAccounts(accounts); |
|
|
|
template.insert("person", p); |
|
|
|
template.insert("person", p); |
|
|
|
|
|
|
|
|
|
|
|
assertNotNull(p.getId()); |
|
|
|
assertNotNull(p.getId()); |
|
|
|
|