use of org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext in project spring-data-elasticsearch by spring-projects.
the class EntityOperationsTest method setUpAll.
@BeforeAll
static void setUpAll() {
mappingContext = new SimpleElasticsearchMappingContext();
mappingContext.setInitialEntitySet(new HashSet<>(Arrays.asList(EntityWithRouting.class)));
mappingContext.afterPropertiesSet();
entityOperations = new EntityOperations(mappingContext);
MappingElasticsearchConverter converter = new MappingElasticsearchConverter(mappingContext, new GenericConversionService());
converter.afterPropertiesSet();
conversionService = converter.getConversionService();
}
use of org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext in project spring-data-elasticsearch by spring-projects.
the class RequestFactoryTests method setUpAll.
@BeforeAll
static void setUpAll() {
SimpleElasticsearchMappingContext mappingContext = new SimpleElasticsearchMappingContext();
mappingContext.setInitialEntitySet(new HashSet<>(Arrays.asList(Person.class, EntityWithSeqNoPrimaryTerm.class)));
mappingContext.afterPropertiesSet();
converter = new MappingElasticsearchConverter(mappingContext, new GenericConversionService());
converter.afterPropertiesSet();
requestFactory = new RequestFactory((converter));
}
use of org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext in project spring-data-elasticsearch by spring-projects.
the class MappingContextBaseTests method setupMappingContext.
private SimpleElasticsearchMappingContext setupMappingContext() {
ElasticsearchConfigurationSupport configurationSupport = new ElasticsearchConfigurationSupport();
SimpleElasticsearchMappingContext mappingContext = configurationSupport.elasticsearchMappingContext(configurationSupport.elasticsearchCustomConversions());
mappingContext.initialize();
return mappingContext;
}
use of org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext in project spring-data-elasticsearch by spring-projects.
the class MappingElasticsearchConverterUnitTests method shouldReturnDefaultConversionService.
@Test
public void shouldReturnDefaultConversionService() {
// given
MappingElasticsearchConverter converter = new MappingElasticsearchConverter(new SimpleElasticsearchMappingContext());
// when
ConversionService conversionService = converter.getConversionService();
// then
assertThat(conversionService).isNotNull();
}
use of org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext in project spring-data-elasticsearch by spring-projects.
the class MappingElasticsearchConverterUnitTests method init.
@BeforeEach
public void init() {
SimpleElasticsearchMappingContext mappingContext = new SimpleElasticsearchMappingContext();
mappingContext.setInitialEntitySet(Collections.singleton(Rifle.class));
mappingContext.afterPropertiesSet();
mappingElasticsearchConverter = new MappingElasticsearchConverter(mappingContext, new GenericConversionService());
mappingElasticsearchConverter.setConversions(new ElasticsearchCustomConversions(Arrays.asList(new ShotGunToMapConverter(), new MapToShotGunConverter())));
mappingElasticsearchConverter.afterPropertiesSet();
sarahConnor = new Person();
sarahConnor.id = "sarah";
sarahConnor.name = "Sarah Connor";
sarahConnor.gender = Gender.MAN;
kyleReese = new Person();
kyleReese.id = "kyle";
kyleReese.gender = Gender.MAN;
kyleReese.name = "Kyle Reese";
t800 = new Person();
t800.id = "t800";
t800.name = "T-800";
t800.gender = Gender.MACHINE;
t800AsMap = Document.create();
t800AsMap.put("id", "t800");
t800AsMap.put("name", "T-800");
t800AsMap.put("gender", "MACHINE");
t800AsMap.put("_class", "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$Person");
observatoryRoad = new Address();
observatoryRoad.city = "Los Angeles";
observatoryRoad.street = "2800 East Observatory Road";
observatoryRoad.location = new Point(-118.3026284D, 34.118347D);
bigBunsCafe = new Place();
bigBunsCafe.setName("Big Buns Cafe");
bigBunsCafe.setCity("Los Angeles");
bigBunsCafe.setStreet("15 South Fremont Avenue");
bigBunsCafe.setLocation(new Point(-118.1545845D, 34.0945637D));
sarahAsMap = Document.create();
sarahAsMap.put("id", "sarah");
sarahAsMap.put("name", "Sarah Connor");
sarahAsMap.put("gender", "MAN");
sarahAsMap.put("_class", "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$Person");
kyleAsMap = Document.create();
kyleAsMap.put("id", "kyle");
kyleAsMap.put("gender", "MAN");
kyleAsMap.put("name", "Kyle Reese");
locationAsMap = Document.create();
locationAsMap.put("lat", 34.118347D);
locationAsMap.put("lon", -118.3026284D);
gratiotAveAsMap = Document.create();
gratiotAveAsMap.put("city", "Los Angeles");
gratiotAveAsMap.put("street", "2800 East Observatory Road");
gratiotAveAsMap.put("location", locationAsMap);
bigBunsCafeAsMap = Document.create();
bigBunsCafeAsMap.put("name", "Big Buns Cafe");
bigBunsCafeAsMap.put("city", "Los Angeles");
bigBunsCafeAsMap.put("street", "15 South Fremont Avenue");
bigBunsCafeAsMap.put("location", new LinkedHashMap<>());
((HashMap<String, Object>) bigBunsCafeAsMap.get("location")).put("lat", 34.0945637D);
((HashMap<String, Object>) bigBunsCafeAsMap.get("location")).put("lon", -118.1545845D);
bigBunsCafeAsMap.put("_class", "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$Place");
gunAsMap = Document.create();
gunAsMap.put("label", "Glock 19");
gunAsMap.put("shotsPerMagazine", 33);
gunAsMap.put("_class", Gun.class.getName());
grenadeAsMap = Document.create();
grenadeAsMap.put("label", "40 mm");
grenadeAsMap.put("_class", Grenade.class.getName());
rifleAsMap = Document.create();
rifleAsMap.put("label", "AR-18 Assault Rifle");
rifleAsMap.put("weight", 3.17D);
rifleAsMap.put("maxShotsPerMagazine", 40);
rifleAsMap.put("_class", "rifle");
shotGunAsMap = Document.create();
shotGunAsMap.put("model", "Ithaca 37 Pump Shotgun");
shotGunAsMap.put("_class", ShotGun.class.getName());
notificationAsMap = Document.create();
notificationAsMap.put("id", 1L);
notificationAsMap.put("fromEmail", "from@email.com");
notificationAsMap.put("toEmail", "to@email.com");
Map<String, Object> data = new HashMap<>();
data.put("documentType", "abc");
data.put("content", null);
notificationAsMap.put("params", data);
notificationAsMap.put("_class", "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$Notification");
}
Aggregations