List of usage examples for org.springframework.data.rest.tests.mongodb Address Address
Address
From source file:org.springframework.data.rest.webmvc.config.JsonPatchHandlerUnitTests.java
@Before public void setUp() { MongoMappingContext context = new MongoMappingContext(); context.getPersistentEntity(User.class); PersistentEntities entities = new PersistentEntities(Arrays.asList(context)); Associations associations = new Associations(mappings, mock(RepositoryRestConfiguration.class)); this.handler = new JsonPatchHandler(new ObjectMapper(), new DomainObjectReader(entities, associations)); Address address = new Address(); address.street = "Foo"; address.zipCode = "Bar"; this.user = new User(); this.user.firstname = "Oliver"; this.user.lastname = "Gierke"; this.user.address = address; }
From source file:org.springframework.data.rest.tests.mongodb.MongoWebTests.java
@Before public void populateProfiles() { mapper.setSerializationInclusion(Include.NON_NULL); Profile twitter = new Profile(); twitter.setPerson(1L);/*w ww .ja va 2 s . co m*/ twitter.setType("Twitter"); Profile linkedIn = new Profile(); linkedIn.setPerson(1L); linkedIn.setType("LinkedIn"); repository.save(Arrays.asList(twitter, linkedIn)); Address address = new Address(); address.street = "ETagDoesntMatchExceptionUnitTests"; address.zipCode = "Bar"; User thomas = new User(); thomas.firstname = "Thomas"; thomas.lastname = "Darimont"; thomas.address = address; userRepository.save(thomas); User oliver = new User(); oliver.firstname = "Oliver"; oliver.lastname = "Gierke"; oliver.address = address; oliver.colleagues = Arrays.asList(thomas); userRepository.save(oliver); thomas.colleagues = Arrays.asList(oliver); userRepository.save(thomas); }
From source file:org.springframework.data.rest.webmvc.json.PersistentEntitySerializationTests.java
/** * @see DATAREST-250// w w w . j a va 2 s . co m */ @Test public void serializesEmbeddedReferencesCorrectly() throws Exception { User user = new User(); user.address = new Address(); user.address.street = "Street"; PersistentEntityResource userResource = PersistentEntityResource.// build(user, repositories.getPersistentEntity(User.class)).// withLink(new Link("/users/1")).// build(); PagedResources<PersistentEntityResource> persistentEntityResource = new PagedResources<PersistentEntityResource>( Arrays.asList(userResource), new PageMetadata(1, 0, 10)); String result = mapper.writeValueAsString(persistentEntityResource); assertThat(JsonPath.read(result, "$._embedded.users[*].address"), is(notNullValue())); }