Merge pull request #27 from Microsoft/cast-jsonarray-to-list

Cast jsonarray to list
This commit is contained in:
weiping 2018-01-12 14:34:01 +08:00 коммит произвёл GitHub
Родитель 72ec322bf0 d77cad44e4
Коммит 580f1bbc72
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
14 изменённых файлов: 146 добавлений и 187 удалений

4
.gitignore поставляемый
Просмотреть файл

@ -40,4 +40,6 @@ hs_err_pid*
# Maven
target
/bin/
!.mvn/wrapper/maven-wrapper.jar
!.mvn/wrapper/maven-wrapper.jar
*.dll

Просмотреть файл

@ -127,6 +127,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Просмотреть файл

@ -9,7 +9,6 @@ package com.microsoft.azure.spring.data.documentdb.core;
import com.microsoft.azure.documentdb.*;
import com.microsoft.azure.documentdb.internal.HttpConstants;
import com.microsoft.azure.spring.data.documentdb.DocumentDbFactory;
import com.microsoft.azure.spring.data.documentdb.core.convert.DocumentDbConverter;
import com.microsoft.azure.spring.data.documentdb.core.convert.MappingDocumentDbConverter;
import com.microsoft.azure.spring.data.documentdb.core.query.Query;
import org.slf4j.Logger;

Просмотреть файл

@ -5,26 +5,24 @@
*/
package com.microsoft.azure.spring.data.documentdb.core.convert;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.azure.documentdb.Document;
import com.microsoft.azure.spring.data.documentdb.core.mapping.DocumentDbPersistentEntity;
import com.microsoft.azure.spring.data.documentdb.core.mapping.DocumentDbPersistentProperty;
import org.apache.commons.lang3.ClassUtils;
import org.json.JSONObject;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.GenericConversionService;
import org.springframework.data.convert.EntityConverter;
import org.springframework.data.mapping.PersistentPropertyAccessor;
import org.springframework.data.mapping.PropertyHandler;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
import org.springframework.data.mapping.model.MappingException;
import java.lang.reflect.Constructor;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
public class MappingDocumentDbConverter
implements EntityConverter<DocumentDbPersistentEntity<?>, DocumentDbPersistentProperty, Object, Document>,
@ -53,26 +51,24 @@ public class MappingDocumentDbConverter
protected <R extends Object> R readInternal(final DocumentDbPersistentEntity<?> entity, Class<R> type,
final Document sourceDocument) {
final R result = instantiate(type);
final ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
try {
final DocumentDbPersistentProperty idProperty = entity.getIdProperty();
final Object idValue = sourceDocument.getId();
final PersistentPropertyAccessor accessor = entity.getPropertyAccessor(result);
final JSONObject jsonObject = new JSONObject(sourceDocument.toJson());
if (idProperty != null) {
// Replace the key id to the actual id field name in domain
jsonObject.remove("id");
jsonObject.put(idProperty.getName(), idValue);
}
final DocumentDbPersistentProperty idProperty = entity.getIdProperty();
final Object idValue = sourceDocument.getId();
if (idProperty != null) {
accessor.setProperty(idProperty, idValue);
return objectMapper.readValue(jsonObject.toString(), type);
} catch (IOException e) {
throw new IllegalStateException("Failed to read the source document " + sourceDocument.toJson()
+ " to target type " + type, e);
}
entity.doWithProperties((PropertyHandler<DocumentDbPersistentProperty>) prop -> {
if (idProperty != null && idProperty.equals(prop)) {
return;
}
accessor.setProperty(prop, sourceDocument.get(prop.getName()));
}
);
return result;
}
@Override
@ -136,18 +132,4 @@ public class MappingDocumentDbConverter
final PersistentPropertyAccessor accessor = entityInformation.getPropertyAccessor(entity);
return new ConvertingPropertyAccessor(accessor, conversionService);
}
private <T> T instantiate(Class<T> tClass) {
try {
final Constructor<T> constructor = (Constructor<T>) tClass.getConstructors()[0];
final List<Object> params = new ArrayList<>();
for (final Class<?> paramType : constructor.getParameterTypes()) {
params.add((paramType.isPrimitive()) ? ClassUtils.primitiveToWrapper(paramType).newInstance() : null);
}
return constructor.newInstance(params.toArray());
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e.getMessage());
}
}
}

Просмотреть файл

@ -6,8 +6,8 @@
package com.microsoft.azure.spring.data.documentdb.repository;
import org.springframework.data.repository.NoRepositoryBean;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.NoRepositoryBean;
import java.io.Serializable;
import java.util.List;

Просмотреть файл

@ -0,0 +1,19 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for
* license information.
*/
package com.microsoft.azure.spring.data.documentdb;
import com.microsoft.azure.spring.data.documentdb.domain.Address;
import java.util.Arrays;
import java.util.List;
public class Constants {
public static final List<String> HOBBIES = Arrays.asList("photography", "fishing");
private static final Address ADDRESS_1 = new Address("201107", "Zixing Road", "Shanghai");
private static final Address ADDRESS_2 = new Address("200000", "Xuhui", "Shanghai");
public static final List<Address> ADDRESSES = Arrays.asList(ADDRESS_1, ADDRESS_2);
}

Просмотреть файл

@ -9,8 +9,10 @@ package com.microsoft.azure.spring.data.documentdb.core;
import com.microsoft.azure.documentdb.ConnectionPolicy;
import com.microsoft.azure.documentdb.ConsistencyLevel;
import com.microsoft.azure.documentdb.DocumentClient;
import com.microsoft.azure.spring.data.documentdb.Constants;
import com.microsoft.azure.spring.data.documentdb.core.convert.MappingDocumentDbConverter;
import com.microsoft.azure.spring.data.documentdb.core.mapping.DocumentDbMappingContext;
import com.microsoft.azure.spring.data.documentdb.domain.Address;
import com.microsoft.azure.spring.data.documentdb.domain.Person;
import org.junit.After;
import org.junit.Before;
@ -27,16 +29,18 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@PropertySource(value = {"classpath:application.properties"})
public class DocumentDbTemplateIT {
private static final String TEST_ID = "template_it_id";
private static final String TEST_NOTEXIST_ID = "non_exist_id";
private static final String TEST_ID = "testid";
private static final String TEST_NOTEXIST_ID = "testid2";
private static final String TEST_DB_NAME = "testdb";
private static final Person TEST_PERSON = new Person(TEST_ID, "testfirstname", "testlastname");
private static final String TEST_DB_NAME = "template_it_db";
private static final List<String> HOBBIES = Constants.HOBBIES;
private static final List<Address> ADDRESSES = Constants.ADDRESSES;
private static final Person TEST_PERSON = new Person(TEST_ID, "testfirstname", "testlastname", HOBBIES, ADDRESSES);
private static final String PARTITION_KEY = "lastName";
@ -88,9 +92,7 @@ public class DocumentDbTemplateIT {
public void testFindAll() {
final List<Person> result = dbTemplate.findAll(Person.class.getSimpleName(), Person.class, null, null);
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0).getId()).isEqualTo(TEST_PERSON.getId());
assertThat(result.get(0).getFirstName()).isEqualTo(TEST_PERSON.getFirstName());
assertThat(result.get(0).getLastName()).isEqualTo(TEST_PERSON.getLastName());
assertThat(result.get(0)).isEqualTo(TEST_PERSON);
}
@Test
@ -101,18 +103,14 @@ public class DocumentDbTemplateIT {
Person.class, PARTITION_KEY, TEST_PERSON.getLastName());
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0).getId()).isEqualTo(TEST_PERSON.getId());
assertThat(result.get(0).getFirstName()).isEqualTo(TEST_PERSON.getFirstName());
assertThat(result.get(0).getLastName()).isEqualTo(TEST_PERSON.getLastName());
assertThat(result.get(0)).isEqualTo(TEST_PERSON);
}
@Test
public void testFindById() {
final Person result = dbTemplate.findById(Person.class.getSimpleName(),
TEST_PERSON.getId(), Person.class, null);
assertThat(result.getId()).isEqualTo(TEST_PERSON.getId());
assertThat(result.getFirstName()).isEqualTo(TEST_PERSON.getFirstName());
assertThat(result.getLastName()).isEqualTo(TEST_PERSON.getLastName());
assertTrue(result.equals(TEST_PERSON));
final Person nullResult = dbTemplate.findById(Person.class.getSimpleName(),
TEST_NOTEXIST_ID, Person.class, null);
@ -125,9 +123,7 @@ public class DocumentDbTemplateIT {
final Person result = dbTemplate.findById(Person.class.getSimpleName(),
TEST_PERSON.getId(), Person.class, TEST_PERSON.getLastName());
assertThat(result.getId()).isEqualTo(TEST_PERSON.getId());
assertThat(result.getFirstName()).isEqualTo(TEST_PERSON.getFirstName());
assertThat(result.getLastName()).isEqualTo(TEST_PERSON.getLastName());
assertTrue(result.equals(TEST_PERSON));
final Person nullResult = dbTemplate.findById(Person.class.getSimpleName(),
TEST_NOTEXIST_ID, Person.class, TEST_PERSON.getLastName());
@ -137,35 +133,31 @@ public class DocumentDbTemplateIT {
@Test
public void testUpdate() {
final Person updated = new Person(TEST_PERSON.getId(), "updatedname",
TEST_PERSON.getLastName());
TEST_PERSON.getLastName(), TEST_PERSON.getHobbies(), TEST_PERSON.getShippingAddresses());
dbTemplate.update(Person.class.getSimpleName(), updated, updated.getId(), null);
final Person result = dbTemplate.findById(Person.class.getSimpleName(),
updated.getId(), Person.class, null);
assertThat(result.getId()).isEqualTo(updated.getId());
assertThat(result.getFirstName()).isEqualTo(updated.getFirstName());
assertThat(result.getLastName()).isEqualTo(updated.getLastName());
assertTrue(result.equals(updated));
}
@Test
public void testUpdatePartition() {
setupPartition();
final Person updated = new Person(TEST_PERSON.getId(), "updatedname",
TEST_PERSON.getLastName());
TEST_PERSON.getLastName(), TEST_PERSON.getHobbies(), TEST_PERSON.getShippingAddresses());
dbTemplate.update(Person.class.getSimpleName(), updated, updated.getId(), updated.getLastName());
final Person result = dbTemplate.findById(Person.class.getSimpleName(),
updated.getId(), Person.class, updated.getLastName());
assertThat(result.getId()).isEqualTo(updated.getId());
assertThat(result.getFirstName()).isEqualTo(updated.getFirstName());
assertThat(result.getLastName()).isEqualTo(updated.getLastName());
assertTrue(result.equals(updated));
}
@Test
public void testDeleteById() {
final Person person2 = new Person("newid", "newfn", "newln");
final Person person2 = new Person("newid", "newfn", "newln", HOBBIES, ADDRESSES);
dbTemplate.insert(person2, null);
assertThat(dbTemplate.findAll(Person.class, null, null).size()).isEqualTo(2);
@ -173,10 +165,7 @@ public class DocumentDbTemplateIT {
final List<Person> result = dbTemplate.findAll(Person.class, null, null);
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0).getId()).isEqualTo(person2.getId());
assertThat(result.get(0).getFirstName()).isEqualTo(person2.getFirstName());
assertThat(result.get(0).getLastName()).isEqualTo(person2.getLastName());
assertTrue(result.get(0).equals(person2));
}
@Test
@ -184,7 +173,7 @@ public class DocumentDbTemplateIT {
setupPartition();
// insert new document with same partition key
final Person person2 = new Person("newid", "newfn", TEST_PERSON.getLastName());
final Person person2 = new Person("newid", "newfn", TEST_PERSON.getLastName(), HOBBIES, ADDRESSES);
dbTemplate.insert(Person.class.getSimpleName(), person2, person2.getLastName());
assertThat(dbTemplate.findAll(Person.class, PARTITION_KEY, person2.getLastName()).size()).isEqualTo(2);
@ -194,10 +183,7 @@ public class DocumentDbTemplateIT {
final List<Person> result = dbTemplate.findAll(Person.class, PARTITION_KEY, person2.getLastName());
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(0).getId()).isEqualTo(person2.getId());
assertThat(result.get(0).getFirstName()).isEqualTo(person2.getFirstName());
assertThat(result.get(0).getLastName()).isEqualTo(person2.getLastName());
assertTrue(result.get(0).equals(person2));
}
private void setupPartition() {

Просмотреть файл

@ -8,22 +8,33 @@ package com.microsoft.azure.spring.data.documentdb.core.converter;
import com.microsoft.azure.documentdb.Document;
import com.microsoft.azure.spring.data.documentdb.Constants;
import com.microsoft.azure.spring.data.documentdb.core.convert.DocumentDbConverter;
import com.microsoft.azure.spring.data.documentdb.domain.Address;
import com.microsoft.azure.spring.data.documentdb.domain.Person;
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
import java.util.Collection;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertTrue;
public class DocumentDbConverterUnitTest {
private static final String id = "testId";
private static final String id = "db_converter_test_id";
private static final String firstName = "testFirstName";
private static final String lastName = "testLastName";
private static final List<String> hobbies = Constants.HOBBIES;
private static final List<Address> addresses = Constants.ADDRESSES;
private static final String idPropertyName = "id";
private static final String firstNamePropertyName = "firstName";
private static final String lastNamePropertyName = "lastName";
private static final String hobbiesPropertyName = "hobbies";
private static final String shippingAddressesPropertyName = "shippingAddresses";
private DocumentDbConverter dbConverter;
@Before
@ -33,15 +44,24 @@ public class DocumentDbConverterUnitTest {
@Test
public void testConvertFromEntityToDocument() {
final Person person = new Person(id, firstName, lastName);
final Person person = new Person(id, firstName, lastName, hobbies, addresses);
final Document document = dbConverter.convertToDocument(person);
assertThat(document.has(idPropertyName)).isTrue();
assertThat(document.has(firstNamePropertyName)).isTrue();
assertThat(document.has(lastNamePropertyName)).isTrue();
assertTrue(document.has(idPropertyName));
assertTrue(document.has(firstNamePropertyName));
assertTrue(document.has(lastNamePropertyName));
assertTrue(document.has(hobbiesPropertyName));
assertTrue(document.has(shippingAddressesPropertyName));
assertThat(document.getId()).isEqualTo(id);
assertThat(document.getString(firstNamePropertyName)).isEqualTo(firstName);
assertThat(document.getString(lastNamePropertyName)).isEqualTo(lastName);
final Collection<String> convertedHobbies = document.getCollection(hobbiesPropertyName, String.class);
assertTrue(hobbies.equals(convertedHobbies));
final Collection<Address> convertedAddresses =
document.getCollection(shippingAddressesPropertyName, Address.class);
assertTrue(addresses.equals(convertedAddresses));
}
@Test
@ -50,12 +70,15 @@ public class DocumentDbConverterUnitTest {
json.put(idPropertyName, id);
json.put(firstNamePropertyName, firstName);
json.put(lastNamePropertyName, lastName);
json.put(hobbiesPropertyName, hobbies);
json.put(shippingAddressesPropertyName, addresses);
final Document document = new Document(JSONObject.valueToString(json));
final Person person = dbConverter.convertFromDocument(document, Person.class);
assertThat(person.getId()).isEqualTo(id);
assertThat(person.getFirstName()).isEqualTo(firstName);
assertThat(person.getLastName()).isEqualTo(lastName);
assertThat(person.getHobbies().equals(hobbies));
assertThat(person.getShippingAddresses().equals(addresses));
}
}

Просмотреть файл

@ -7,43 +7,17 @@ package com.microsoft.azure.spring.data.documentdb.domain;
import com.microsoft.azure.spring.data.documentdb.core.mapping.Document;
import com.microsoft.azure.spring.data.documentdb.core.mapping.PartitionKey;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.data.annotation.Id;
@Document(ru = "1000")
@Data
@AllArgsConstructor
public class Address {
@Id
String postalCode;
String street;
@PartitionKey
String city;
public Address(String postalCode, String city, String street) {
this.postalCode = postalCode;
this.city = city;
this.street = street;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getPostalCode() {
return this.postalCode;
}
public void setPostalCode(String code) {
this.postalCode = code;
}
}

Просмотреть файл

@ -6,44 +6,17 @@
package com.microsoft.azure.spring.data.documentdb.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.List;
@Data
@AllArgsConstructor
public class Person {
private String id;
private String firstName;
private String lastName;
private String id;
public Person() {
this(null, null, null);
}
public Person(String id, String fname, String lname) {
this.firstName = fname;
this.lastName = lname;
this.id = id;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String fname) {
this.firstName = fname;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
private List<String> hobbies;
private List<Address> shippingAddresses;
}

Просмотреть файл

@ -23,9 +23,9 @@ import static org.assertj.core.api.Assertions.assertThat;
@ContextConfiguration(classes = ContactRepositoryConfig.class)
public class AddressRepositoryIT {
private static final Address TEST_ADDRESS1_PARTITION1 = new Address("111", "redmond", "111st avenue");
private static final Address TEST_ADDRESS2_PARTITION1 = new Address("222", "redmond", "98th street");
private static final Address TEST_ADDRESS1_PARTITION2 = new Address("333", "bellevue", "103rd street");
private static final Address TEST_ADDRESS1_PARTITION1 = new Address("111", "111st avenue", "redmond");
private static final Address TEST_ADDRESS2_PARTITION1 = new Address("222", "98th street", "redmond");
private static final Address TEST_ADDRESS1_PARTITION2 = new Address("333", "103rd street", "bellevue");
@Autowired
AddressRepository repository;
@ -83,8 +83,8 @@ public class AddressRepositoryIT {
@Test
public void testUpdateEntity() {
final Address updatedAddress = new Address(TEST_ADDRESS1_PARTITION1.getPostalCode(),
TEST_ADDRESS1_PARTITION1.getCity(), "new street");
final Address updatedAddress = new Address(TEST_ADDRESS1_PARTITION1.getPostalCode(), "new street",
TEST_ADDRESS1_PARTITION1.getCity());
repository.update(updatedAddress, updatedAddress.getCity());

Просмотреть файл

@ -5,32 +5,15 @@
*/
package com.microsoft.azure.spring.data.documentdb.repository;
import lombok.AllArgsConstructor;
import lombok.Data;
import org.springframework.data.annotation.Id;
@Data
@AllArgsConstructor
public class Contact {
@Id
private String logicId;
private String title;
public Contact(String id, String title) {
this.logicId = id;
this.title = title;
}
public String getLogicId() {
return logicId;
}
public void setLogicId(String logicId) {
this.logicId = logicId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}

Просмотреть файл

@ -6,7 +6,9 @@
package com.microsoft.azure.spring.data.documentdb.repository;
import com.microsoft.azure.spring.data.documentdb.Constants;
import com.microsoft.azure.spring.data.documentdb.core.DocumentDbOperations;
import com.microsoft.azure.spring.data.documentdb.domain.Address;
import com.microsoft.azure.spring.data.documentdb.domain.Person;
import com.microsoft.azure.spring.data.documentdb.repository.support.DocumentDbEntityInformation;
import com.microsoft.azure.spring.data.documentdb.repository.support.SimpleDocumentDbRepository;
@ -17,6 +19,7 @@ import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.anyString;
@ -25,8 +28,10 @@ import static org.mockito.Mockito.when;
@RunWith(MockitoJUnitRunner.class)
public class SimpleDocumentDbRepositoryUnitTest {
private static final Person TEST_PERSON =
new Person("test_person", "firstname", "lastname",
Constants.HOBBIES, Constants.ADDRESSES);
private static final Person TEST_PERSON = new Person("aaa", "firstname", "lastname");
SimpleDocumentDbRepository<Person, String> repository;
@Mock
DocumentDbOperations dbOperations;
@ -49,8 +54,9 @@ public class SimpleDocumentDbRepositoryUnitTest {
public void testSave() {
repository.save(TEST_PERSON);
assertEquals(1, repository.findAll(TEST_PERSON.getLastName()).size());
assertEquals(TEST_PERSON.getFirstName(), repository.findAll(TEST_PERSON.getLastName()).get(0).getFirstName());
final List<Person> result = repository.findAll(TEST_PERSON.getLastName());
assertEquals(1, result.size());
assertEquals(TEST_PERSON, result.get(0));
}
@Test
@ -60,23 +66,21 @@ public class SimpleDocumentDbRepositoryUnitTest {
repository.save(TEST_PERSON);
final Person result = repository.findOne(TEST_PERSON.getId(), TEST_PERSON.getLastName());
assertEquals(result.getId(), TEST_PERSON.getId());
assertEquals(result.getFirstName(), TEST_PERSON.getFirstName());
assertEquals(result.getLastName(), TEST_PERSON.getLastName());
assertEquals(TEST_PERSON, result);
}
@Test
public void testUpdate() {
final Person updatedPerson = new Person(TEST_PERSON.getId(), "updated", "updated");
final List<Address> updatedAddress =
Arrays.asList(new Address("12345", "updated city", "updated street"));
final Person updatedPerson =
new Person(TEST_PERSON.getId(), "updated", "updated",
Arrays.asList("updated hobbies"), updatedAddress);
repository.update(updatedPerson);
when(dbOperations.findById(anyString(), any(), any(), anyString())).thenReturn(updatedPerson);
final Person result = repository.findOne(TEST_PERSON.getId(), TEST_PERSON.getLastName());
assertEquals(result.getId(), updatedPerson.getId());
assertEquals(result.getFirstName(), updatedPerson.getFirstName());
assertEquals(result.getLastName(), updatedPerson.getLastName());
assertEquals(updatedPerson, result);
}
}

Просмотреть файл

@ -5,17 +5,26 @@
*/
package com.microsoft.azure.spring.data.documentdb.repository.support;
import com.microsoft.azure.spring.data.documentdb.Constants;
import com.microsoft.azure.spring.data.documentdb.core.mapping.Document;
import com.microsoft.azure.spring.data.documentdb.domain.Address;
import com.microsoft.azure.spring.data.documentdb.domain.Person;
import org.junit.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class DocumentDbEntityInformationUnitTest {
private static final String ID = "entity_info_test_id";
private static final String FIRST_NAME = "first name";
private static final String LAST_NAME = "last name";
private static final List<String> HOBBIES = Constants.HOBBIES;
private static final List<Address> ADDRESSES = Constants.ADDRESSES;
@Test
public void testGetId() {
final Person testPerson = new Person("test", "test", "test");
final Person testPerson = new Person(ID, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES);
final DocumentDbEntityInformation<Person, String> entityInformation =
new DocumentDbEntityInformation<Person, String>(Person.class);