Search in sources :

Example 6 with SimpleElasticsearchMappingContext

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();
}
Also used : SimpleElasticsearchMappingContext(org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext) MappingElasticsearchConverter(org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 7 with SimpleElasticsearchMappingContext

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));
}
Also used : SimpleElasticsearchMappingContext(org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext) MappingElasticsearchConverter(org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 8 with SimpleElasticsearchMappingContext

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;
}
Also used : SimpleElasticsearchMappingContext(org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext) ElasticsearchConfigurationSupport(org.springframework.data.elasticsearch.config.ElasticsearchConfigurationSupport)

Example 9 with SimpleElasticsearchMappingContext

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();
}
Also used : SimpleElasticsearchMappingContext(org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext) ConversionService(org.springframework.core.convert.ConversionService) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) Test(org.junit.jupiter.api.Test)

Example 10 with SimpleElasticsearchMappingContext

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");
}
Also used : SimpleElasticsearchMappingContext(org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) GeoJsonMultiPoint(org.springframework.data.elasticsearch.core.geo.GeoJsonMultiPoint) Point(org.springframework.data.geo.Point) GeoPoint(org.springframework.data.elasticsearch.core.geo.GeoPoint) GeoJsonPoint(org.springframework.data.elasticsearch.core.geo.GeoJsonPoint) GeoJsonLineString(org.springframework.data.elasticsearch.core.geo.GeoJsonLineString) GeoJsonMultiLineString(org.springframework.data.elasticsearch.core.geo.GeoJsonMultiLineString) GenericConversionService(org.springframework.core.convert.support.GenericConversionService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SimpleElasticsearchMappingContext (org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext)23 Test (org.junit.jupiter.api.Test)9 BeforeEach (org.junit.jupiter.api.BeforeEach)7 MappingElasticsearchConverter (org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverter)6 GenericConversionService (org.springframework.core.convert.support.GenericConversionService)5 GeoJsonLineString (org.springframework.data.elasticsearch.core.geo.GeoJsonLineString)3 GeoJsonMultiLineString (org.springframework.data.elasticsearch.core.geo.GeoJsonMultiLineString)3 ArrayList (java.util.ArrayList)2 BeforeAll (org.junit.jupiter.api.BeforeAll)2 DisplayName (org.junit.jupiter.api.DisplayName)2 Document (org.springframework.data.elasticsearch.core.document.Document)2 SpringIntegrationTest (org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest)2 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Bean (org.springframework.context.annotation.Bean)1 ConversionService (org.springframework.core.convert.ConversionService)1 Converter (org.springframework.core.convert.converter.Converter)1 IsNewAwareAuditingHandler (org.springframework.data.auditing.IsNewAwareAuditingHandler)1