List of usage examples for org.springframework.data.mongodb.core.mapping PersonMapProperty setAccounts
public void setAccounts(Map<String, AccountPojo> accounts)
From source file:org.springframework.data.mongodb.core.mapping.MappingTests.java
@Test public void testPersonMapProperty() { PersonMapProperty p = new PersonMapProperty(1234567, "Map", "PropertyPath"); Map<String, AccountPojo> accounts = new HashMap<String, AccountPojo>(); AccountPojo checking = new AccountPojo("checking", 1000.0f); AccountPojo savings = new AccountPojo("savings", 10000.0f); accounts.put("checking", checking); accounts.put("savings", savings); p.setAccounts(accounts); template.insert(p);/*from w ww .ja v a 2s . com*/ assertNotNull(p.getId()); List<PersonMapProperty> result = template.find(new Query(Criteria.where("ssn").is(1234567)), PersonMapProperty.class); assertThat(result.size(), is(1)); assertThat(result.get(0).getAccounts().size(), is(2)); assertThat(result.get(0).getAccounts().get("checking").getBalance(), is(1000.0f)); }