Skip to content
Snippets Groups Projects
Commit 759388ad authored by Rustam Lotsmanenko (EPAM)'s avatar Rustam Lotsmanenko (EPAM)
Browse files

Merge branch 'master' into array-of-objects

# Conflicts:
#	indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessor.java
parents 31f562f3 ef216369
No related branches found
No related tags found
1 merge request!142Array of Objects support by Indexer (GONRG-2028)
Showing
with 2098 additions and 146 deletions
......@@ -30,6 +30,7 @@ import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.search.Preconditions;
import org.opengroup.osdu.indexer.schema.converter.config.SchemaConverterConfig;
import org.opengroup.osdu.indexer.schema.converter.config.SchemaConverterPropertiesConfig;
import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
import org.opengroup.osdu.indexer.schema.converter.tags.AllOfItem;
import org.opengroup.osdu.indexer.schema.converter.tags.Definition;
import org.opengroup.osdu.indexer.schema.converter.tags.Definitions;
......@@ -38,7 +39,6 @@ import org.opengroup.osdu.indexer.schema.converter.tags.TypeProperty;
public class PropertiesProcessor {
private JaxRsDpsLog log;
private SchemaConverterConfig schemaConverterConfig;
private static final String TYPE_KEY = "type";
......@@ -50,12 +50,13 @@ public class PropertiesProcessor {
private final String pathPrefix;
private final String pathPrefixWithDot;
public PropertiesProcessor(Definitions definitions, JaxRsDpsLog log, SchemaConverterConfig schemaConverterConfig) {
this(definitions, null, log, schemaConverterConfig);
private final List<String> errors = new LinkedList<>();
public PropertiesProcessor(Definitions definitions, SchemaConverterConfig schemaConverterConfig) {
this(definitions, null, schemaConverterConfig);
}
public PropertiesProcessor(Definitions definitions, String pathPrefix, JaxRsDpsLog log, SchemaConverterConfig schemaConverterConfig) {
this.log = log;
public PropertiesProcessor(Definitions definitions, String pathPrefix, SchemaConverterConfig schemaConverterConfig) {
this.definitions = definitions;
this.pathPrefix = pathPrefix;
this.pathPrefixWithDot = Objects.isNull(pathPrefix) || pathPrefix.isEmpty() ? "" : pathPrefix + ".";
......@@ -63,55 +64,71 @@ public class PropertiesProcessor {
}
public Stream<Map<String, Object>> processItem(AllOfItem allOfItem) {
Preconditions.checkNotNull(allOfItem, "allOfItem cannot be null");
try {
Preconditions.checkNotNull(allOfItem, "allOfItem cannot be null");
Stream<Map<String, Object>> ofItems = processOfItems(allOfItem.getAllOf(), allOfItem.getAnyOf(), allOfItem.getOneOf());
Stream<Map<String, Object>> ofItems = processOfItems(allOfItem.getAllOf(), allOfItem.getAnyOf(), allOfItem.getOneOf());
if (Objects.nonNull(ofItems)) {
return ofItems;
}
if (Objects.nonNull(ofItems)) {
return ofItems;
}
String ref = allOfItem.getRef();
String ref = allOfItem.getRef();
return Objects.isNull(ref) ?
allOfItem.getProperties().entrySet().stream().flatMap(this::processPropertyEntry) : processRef(ref);
return Objects.isNull(ref) ?
allOfItem.getProperties().entrySet().stream().flatMap(this::processPropertyEntry) : processRef(ref);
} catch (RuntimeException exception) {
errors.add(exception.getMessage());
return Stream.empty();
}
}
public Stream<Map<String, Object>> processRef(String ref) {
Preconditions.checkNotNull(ref, "reference cannot be null");
if (!ref.contains(DEF_PREFIX)) {
log.warning("Unknown definition:" + ref);
return Stream.empty();
}
try {
if (!ref.contains(DEF_PREFIX)) {
throw new SchemaProcessingException("Unknown definition format, no prefix:" + ref);
}
String definitionSubRef = ref.substring(DEF_PREFIX.length());
String definitionSubRef = ref.substring(DEF_PREFIX.length());
String definitionIdentity = getDefinitionIdentity(definitionSubRef);
String definitionIdentity = getDefinitionIdentity(definitionSubRef);
if (schemaConverterConfig.getSkippedDefinitions().contains(definitionIdentity)) {
return Stream.empty();
}
if (schemaConverterConfig.getSkippedDefinitions().contains(definitionIdentity)) {
return Stream.empty();
}
if (Objects.nonNull(schemaConverterConfig.getSpecialDefinitionsMap().get(definitionIdentity))) {
return storageSchemaEntry(
schemaConverterConfig.getSpecialDefinitionsMap().get(definitionIdentity) + getDefinitionColonVersion(definitionSubRef),
pathPrefix);
}
if (Objects.nonNull(schemaConverterConfig.getSpecialDefinitionsMap().get(definitionIdentity))) {
return storageSchemaEntry(
schemaConverterConfig.getSpecialDefinitionsMap().get(definitionIdentity) + getDefinitionColonVersion(definitionSubRef),
pathPrefix);
}
Definition definition = definitions.getDefinition(definitionSubRef);
Optional.ofNullable(definition).orElseThrow(() ->
new AppException(HttpStatus.SC_NOT_FOUND, "Failed to find definition:" + definitionSubRef,
"Unknown definition:" + definitionSubRef));
Definition definition = definitions.getDefinition(definitionSubRef);
Optional.ofNullable(definition).orElseThrow(() ->
new SchemaProcessingException("Failed to find definition:" + definitionSubRef));
Stream<Map<String, Object>> ofItems =
processOfItems(definition.getAllOf(), definition.getAnyOf(), definition.getOneOf());
Stream<Map<String, Object>> ofItems =
processOfItems(definition.getAllOf(), definition.getAnyOf(), definition.getOneOf());
if (Objects.nonNull(ofItems)) {
return ofItems;
if (Objects.nonNull(ofItems)) {
return ofItems;
}
return processProperties(definition.getProperties());
} catch (RuntimeException exception) {
errors.add(exception.getMessage());
return Stream.empty();
}
}
public Stream<Map<String, Object>> processProperties(Map<String, TypeProperty> properties) {
return properties.entrySet().stream().flatMap(this::processPropertyEntry);
}
return processProperties(definition.getProperties());
public List<String> getErrors() {
return errors;
}
private String getDefinitionIdentity(String definitionSubRef) {
......@@ -156,21 +173,21 @@ public class PropertiesProcessor {
return ofItems;
}
public Stream<Map<String, Object>> processProperties(Map<String, TypeProperty> properties) {
return properties.entrySet().stream().flatMap(this::processPropertyEntry);
}
private Stream<Map<String, Object>> processPropertyEntry(Map.Entry<String, TypeProperty> entry) {
Preconditions.checkNotNull(entry, "entry cannot be null");
try {
if ("object".equals(entry.getValue().getType())
&& Objects.isNull(entry.getValue().getItems())
&& Objects.isNull(entry.getValue().getRef())
&& Objects.isNull(entry.getValue().getProperties())) {
return Stream.empty();
}
if ("object".equals(entry.getValue().getType())
&& Objects.isNull(entry.getValue().getItems())
&& Objects.isNull(entry.getValue().getRef())
&& Objects.isNull(entry.getValue().getProperties())) {
return Stream.empty();
}
if ("array".equals(entry.getValue().getType())) {
if (schemaConverterConfig.getSupportedArrayTypes().contains(entry.getValue().getItems().getType())) {
return storageSchemaEntry("[]" + getTypeByDefinitionProperty(entry.getValue()), pathPrefixWithDot + entry.getKey());
}
if ("array".equals(entry.getValue().getType())) {
Items items = entry.getValue().getItems();
......@@ -182,27 +199,37 @@ public class PropertiesProcessor {
return storageSchemaEntry("[]" + getTypeByDefinitionProperty(entry.getValue()), pathPrefixWithDot + entry.getKey());
}
return Stream.empty();
}
return Stream.empty();
}
Stream<Map<String, Object>> ofItems = processOfItems(entry);
Stream<Map<String, Object>> ofItems = processOfItems(entry);
if (Objects.nonNull(ofItems)) {
return ofItems;
}
if (Objects.nonNull(ofItems)) {
return ofItems;
}
if (Objects.nonNull(entry.getValue().getProperties())) {
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(definitions, pathPrefixWithDot + entry.getKey()
, log, new SchemaConverterPropertiesConfig());
return entry.getValue().getProperties().entrySet().stream().flatMap(propertiesProcessor::processPropertyEntry);
}
if (Objects.nonNull(entry.getValue().getProperties())) {
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(definitions, pathPrefixWithDot + entry.getKey()
, new SchemaConverterPropertiesConfig());
Stream<Map<String, Object>> result = entry.getValue().getProperties().entrySet().stream().flatMap(propertiesProcessor::processPropertyEntry);
errors.addAll(propertiesProcessor.getErrors());
return result;
}
if (Objects.nonNull(entry.getValue().getRef())) {
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(definitions
, pathPrefixWithDot + entry.getKey(), new SchemaConverterPropertiesConfig());
Stream<Map<String, Object>> refResult = propertiesProcessor.processRef(entry.getValue().getRef());
errors.addAll(propertiesProcessor.getErrors());
return refResult;
}
if (Objects.nonNull(entry.getValue().getRef())) {
return new PropertiesProcessor(definitions, pathPrefixWithDot + entry.getKey(), log, new SchemaConverterPropertiesConfig())
.processRef(entry.getValue().getRef());
return storageSchemaEntry(getTypeByDefinitionProperty(entry.getValue()), pathPrefixWithDot + entry.getKey());
} catch (RuntimeException ex) {
errors.add(ex.getMessage());
return Stream.empty();
}
return storageSchemaEntry(getTypeByDefinitionProperty(entry.getValue()), pathPrefixWithDot + entry.getKey());
}
private Stream<Map<String, Object>> processComplexTypeItems(Entry<String, TypeProperty> entry, Items items) {
......@@ -240,33 +267,36 @@ public class PropertiesProcessor {
if (Objects.nonNull(entry.getValue().getAllOf())) {
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(definitions, pathPrefixWithDot + entry.getKey()
, log, new SchemaConverterPropertiesConfig());
, new SchemaConverterPropertiesConfig());
ofItems = entry.getValue().getAllOf().stream().flatMap(propertiesProcessor::processItem);
errors.addAll(propertiesProcessor.getErrors());
}
if (Objects.nonNull(entry.getValue().getAnyOf())) {
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(definitions, pathPrefixWithDot + entry.getKey()
, log, new SchemaConverterPropertiesConfig());
, new SchemaConverterPropertiesConfig());
ofItems = Stream.concat(Optional.ofNullable(ofItems).orElseGet(Stream::empty),
entry.getValue().getAnyOf().stream().flatMap(propertiesProcessor::processItem));
errors.addAll(propertiesProcessor.getErrors());
}
if (Objects.nonNull(entry.getValue().getOneOf())) {
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(definitions, pathPrefixWithDot + entry.getKey()
, log, new SchemaConverterPropertiesConfig());
, new SchemaConverterPropertiesConfig());
ofItems = Stream.concat(Optional.ofNullable(ofItems).orElseGet(Stream::empty),
entry.getValue().getOneOf().stream().flatMap(propertiesProcessor::processItem));
errors.addAll(propertiesProcessor.getErrors());
}
return ofItems;
}
private Stream<Map<String, Object>> storageSchemaEntry(String kind, String path) {
Preconditions.checkNotNullOrEmpty(kind, "kind cannot be null or empty");
Preconditions.checkNotNullOrEmpty(path, "path cannot be null or empty");
Preconditions.checkNotNullOrEmpty(kind, String.format("kind cannot be null or empty for path '%s'", path));
Map<String, Object> map = new HashMap<>();
map.put("kind", kind);
......
......@@ -16,11 +16,10 @@ package org.opengroup.osdu.indexer.schema.converter;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.search.Preconditions;
import org.opengroup.osdu.indexer.schema.converter.config.SchemaConverterConfig;
import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
import org.opengroup.osdu.indexer.schema.converter.interfaces.SchemaToStorageFormat;
import org.opengroup.osdu.indexer.schema.converter.tags.PropertiesData;
import org.opengroup.osdu.indexer.schema.converter.tags.SchemaRoot;
......@@ -37,7 +36,6 @@ import java.util.stream.Collectors;
public class SchemaToStorageFormatImpl implements SchemaToStorageFormat {
private ObjectMapper objectMapper;
private JaxRsDpsLog log;
private SchemaConverterConfig schemaConverterConfig;
@Inject
......@@ -45,7 +43,6 @@ public class SchemaToStorageFormatImpl implements SchemaToStorageFormat {
Preconditions.checkNotNull(objectMapper, "objectMapper cannot be null");
this.objectMapper = objectMapper;
this.log = log;
this.schemaConverterConfig = schemaConverterConfig;
}
......@@ -68,7 +65,7 @@ public class SchemaToStorageFormatImpl implements SchemaToStorageFormat {
try {
return objectMapper.readValue(schemaServiceFormat, SchemaRoot.class);
} catch (JsonProcessingException e) {
throw new AppException(HttpStatus.SC_BAD_REQUEST, "Loading shchem error", "Failed to load schema", e);
throw new SchemaProcessingException("Failed to parse the schema");
}
}
......@@ -76,7 +73,7 @@ public class SchemaToStorageFormatImpl implements SchemaToStorageFormat {
try {
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(schemaServiceFormat);
} catch (JsonProcessingException e) {
throw new AppException(HttpStatus.SC_UNPROCESSABLE_ENTITY, "Saving JSON error", "Failed to save a JSON file", e);
throw new SchemaProcessingException("Failed to save the JSON file");
}
}
......@@ -84,43 +81,49 @@ public class SchemaToStorageFormatImpl implements SchemaToStorageFormat {
Preconditions.checkNotNull(objectMapper, "schemaServiceSchema cannot be null");
Preconditions.checkNotNullOrEmpty(kind, "kind cannot be null or empty");
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(schemaServiceSchema.getDefinitions(), log, schemaConverterConfig);
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(schemaServiceSchema.getDefinitions(), schemaConverterConfig);
final List<Map<String, Object>> storageSchemaItems = new ArrayList<>();
if (schemaServiceSchema.getProperties() != null) {
PropertiesData schemaData = schemaServiceSchema.getProperties().getData();
if (!Objects.isNull(schemaData)) {
if (schemaData.getAllOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getAllOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getAnyOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getAnyOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getOneOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getOneOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getRef() != null) {
storageSchemaItems.addAll(propertiesProcessor.processRef(schemaData.getRef())
.collect(Collectors.toList()));
}
if (schemaData.getProperties() != null) {
storageSchemaItems.addAll(propertiesProcessor.processProperties(schemaData.getProperties())
.collect(Collectors.toList()));
}
}
} else {
log.warning("Schema doesn't have properties, kind:" + kind);
if (schemaServiceSchema.getProperties() == null) {
throw new SchemaProcessingException(String.format("Schema doesn't have data section, kind: %s", kind));
}
PropertiesData schemaData = schemaServiceSchema.getProperties().getData();
if (Objects.isNull(schemaData)) {
throw new SchemaProcessingException(String.format("Schema doesn't have properties section, kind: %s", kind));
}
if (schemaData.getAllOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getAllOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getAnyOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getAnyOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getOneOf() != null) {
storageSchemaItems.addAll(schemaServiceSchema.getProperties().getData().getOneOf().stream()
.flatMap(propertiesProcessor::processItem)
.collect(Collectors.toList()));
}
if (schemaData.getRef() != null) {
storageSchemaItems.addAll(propertiesProcessor.processRef(schemaData.getRef())
.collect(Collectors.toList()));
}
if (schemaData.getProperties() != null) {
storageSchemaItems.addAll(propertiesProcessor.processProperties(schemaData.getProperties())
.collect(Collectors.toList()));
}
if (!propertiesProcessor.getErrors().isEmpty()) {
throw new SchemaProcessingException(String.format("Errors occurred during parsing the schema, kind: %s | errors: %s" ,
kind, String.join(",", propertiesProcessor.getErrors())));
}
final Map<String, Object> result = new LinkedHashMap<>();
......@@ -129,5 +132,4 @@ public class SchemaToStorageFormatImpl implements SchemaToStorageFormat {
return result;
}
}
package org.opengroup.osdu.indexer.schema.converter.exeption;
public class SchemaProcessingException extends RuntimeException {
public SchemaProcessingException(final String message) {
super(message);
}
}
......@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package org.opengroup.osdu.indexer.service.impl;
package org.opengroup.osdu.indexer.service;
import com.google.api.client.http.HttpMethods;
import org.apache.http.HttpStatus;
......@@ -22,9 +22,8 @@ import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.HttpResponse;
import org.opengroup.osdu.core.common.provider.interfaces.IRequestInfo;
import org.opengroup.osdu.indexer.config.IndexerConfigurationProperties;
import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
import org.opengroup.osdu.indexer.schema.converter.interfaces.SchemaToStorageFormat;
import org.opengroup.osdu.indexer.service.SchemaService;
import org.opengroup.osdu.indexer.service.StorageService;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
......@@ -59,7 +58,17 @@ public class SchemaProviderImpl implements SchemaService {
@Override
public String getSchema(String kind) throws URISyntaxException, UnsupportedEncodingException {
String schemaServiceSchema = getFromSchemaService(kind);
String schemaServiceSchema;
try {
schemaServiceSchema = getFromSchemaService(kind);
} catch (SchemaProcessingException ex) {
log.error(ex.getMessage(), ex);
return null;
} catch (RuntimeException ex) {
log.error(String.format("Failed to get the schema from the Schema service, kind: %s | message: %s", kind, ex.getMessage()), ex);
return null;
}
return Objects.nonNull(schemaServiceSchema) ? schemaServiceSchema : getFromStorageService(kind);
}
......@@ -98,5 +107,4 @@ public class SchemaProviderImpl implements SchemaService {
return this.urlFetchService.sendRequest(request);
}
}
......@@ -18,7 +18,6 @@ import com.google.common.collect.ImmutableMap;
import org.junit.Test;
import org.mockito.Mockito;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.indexer.schema.converter.config.SchemaConverterPropertiesConfig;
import org.opengroup.osdu.indexer.schema.converter.tags.AllOfItem;
import org.opengroup.osdu.indexer.schema.converter.tags.Definition;
......@@ -37,27 +36,29 @@ public class PropertiesProcessorTest {
private static final String PATH = "given_path";
private static final String DEFINITIONS_PREFIX = "#/definitions/";
@Test(expected = AppException.class)
public void should_fail_on_unknown_reference_definition() {
JaxRsDpsLog log = Mockito.mock(JaxRsDpsLog.class);
@Test
public void should_fail_on_bad_reference_definition() {
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(Mockito.mock(Definitions.class), new SchemaConverterPropertiesConfig());
propertiesProcessor.processRef(DEFINITIONS_PREFIX + "unknownDefinition");
assertEquals(1, propertiesProcessor.getErrors().size());
}
new PropertiesProcessor(Mockito.mock(Definitions.class), log, new SchemaConverterPropertiesConfig())
.processRef(DEFINITIONS_PREFIX + "unknownDefinition");
@Test
public void should_fail_on_wrong_definition_format() {
PropertiesProcessor propertiesProcessor = new PropertiesProcessor(Mockito.mock(Definitions.class), new SchemaConverterPropertiesConfig());
propertiesProcessor.processRef("unknownDefinition");
assertEquals(1, propertiesProcessor.getErrors().size());
}
@Test
public void should_not_process_special_reference() {
JaxRsDpsLog log = Mockito.mock(JaxRsDpsLog.class);
assertFalse(new PropertiesProcessor(null, log, new SchemaConverterPropertiesConfig())
assertFalse(new PropertiesProcessor(null, new SchemaConverterPropertiesConfig())
.processRef(DEFINITIONS_PREFIX + "a:b:anyCrsGeoJsonFeatureCollection:1.0.0").findAny().isPresent());
}
@Test
public void should_return_special_type() {
JaxRsDpsLog log = Mockito.mock(JaxRsDpsLog.class);
String res = new PropertiesProcessor(null, PATH, log, new SchemaConverterPropertiesConfig())
String res = new PropertiesProcessor(null, PATH, new SchemaConverterPropertiesConfig())
.processRef(DEFINITIONS_PREFIX + "a:b:core_dl_geopoint:1.0.0").map(Object::toString).reduce("", String::concat);
assertEquals("{path=" + PATH + ", kind=core:dl:geopoint:1.0.0}", res);
}
......@@ -81,7 +82,7 @@ public class PropertiesProcessorTest {
String defName = "a:b:defName:1.0.0";
definitions.add(defName, definition);
String res = new PropertiesProcessor(definitions, PATH, log, new SchemaConverterPropertiesConfig())
String res = new PropertiesProcessor(definitions, PATH, new SchemaConverterPropertiesConfig())
.processRef(DEFINITIONS_PREFIX + defName).map(Object::toString).reduce("", String::concat);
assertEquals(res, "{path="+ PATH + "." + propertyName + ", kind=string}");
}
......@@ -99,7 +100,7 @@ public class PropertiesProcessorTest {
properties.put(PATH, property);
allOfItem.setProperties(properties);
String res = new PropertiesProcessor(Mockito.mock(Definitions.class), log, new SchemaConverterPropertiesConfig())
String res = new PropertiesProcessor(Mockito.mock(Definitions.class), new SchemaConverterPropertiesConfig())
.processItem(allOfItem).map(Object::toString).reduce("", String::concat);
assertEquals("{path=" + PATH + ", kind=int}", res);
}
......
......@@ -20,6 +20,7 @@ import org.junit.Test;
import org.mockito.Mockito;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.indexer.schema.converter.config.SchemaConverterPropertiesConfig;
import org.opengroup.osdu.indexer.schema.converter.exeption.SchemaProcessingException;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
......@@ -54,6 +55,11 @@ public class SchemaToStorageFormatImplTest {
testSingleFile("/converter/new-definitions-format/colons-sample.json", "osdu:osdu:Wellbore:1.0.0");
}
@Test(expected = SchemaProcessingException.class)
public void wrongDefinitions() {
testSingleFile("/converter/bad-schema/wrong-definitions-and-missed-type.json", KIND);
}
@Test
public void firstSchemaPassed() {
testSingleFile("/converter/basic/schema.json", "osdu:osdu:Wellbore:1.0.0");
......
......@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.package org.opengroup.osdu.indexer.service.impl;
package org.opengroup.osdu.indexer.service.impl;
package org.opengroup.osdu.indexer.service;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
......@@ -70,7 +70,7 @@ public class SchemaProviderImplTest {
org.opengroup.osdu.core.common.model.http.HttpResponse httpResponse =
mock(org.opengroup.osdu.core.common.model.http.HttpResponse.class);
when(httpResponse.getResponseCode()).thenReturn(HttpStatus.SC_OK);
when(httpResponse.getBody()).thenReturn("{}");
when(httpResponse.getBody()).thenReturn("{ \"properties\" : { \"data\": {} } }");
when(urlFetchService.sendRequest(any())).thenReturn(httpResponse);
String schema = sut.getSchema("fake");
......@@ -140,7 +140,7 @@ public class SchemaProviderImplTest {
String kind = "tenant:test:test:1.0.0";
SchemaProviderImpl schemaService = Mockito.mock(SchemaProviderImpl.class);
PowerMockito.when(schemaService.getSchema(any())).thenCallRealMethod();
when(schemaService.getSchema(any())).thenCallRealMethod();
InOrder inOrder = inOrder(schemaService);
......
......@@ -113,12 +113,6 @@
},
"data": {
"allOf": [
{
"$ref": "../abstract/AbstractWPCGroupType.1.0.0.json"
},
{
"$ref": "../abstract/AbstractWorkProductComponent.1.0.0.json"
},
{
"type": "object",
"properties": {
......
......@@ -152,14 +152,6 @@
"type": "string"
}
},
"SpatialPoint": {
"description": "A centroid point that reflects the locale of the content of the work product (location of the subject matter).",
"$ref": "../abstract/AbstractSpatialLocation.1.0.0.json"
},
"SpatialArea": {
"description": "A polygon boundary that reflects the locale of the content of the work product (location of the subject matter).",
"$ref": "../abstract/AbstractSpatialLocation.1.0.0.json"
},
"SubmitterName": {
"type": "string",
"description": "Name of the person that first submitted the work product package to OSDU."
......
......@@ -29,7 +29,7 @@ import org.opengroup.osdu.indexer.provider.interfaces.ISchemaCache;
import org.opengroup.osdu.core.common.model.indexer.IndexSchema;
import org.opengroup.osdu.core.common.model.http.RequestStatus;
import org.opengroup.osdu.core.common.search.IndicesService;
import org.opengroup.osdu.indexer.service.impl.SchemaProviderImpl;
import org.opengroup.osdu.indexer.service.SchemaProviderImpl;
import org.opengroup.osdu.indexer.util.ElasticClientHandler;
import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver;
import org.powermock.core.classloader.annotations.PrepareForTest;
......
......@@ -54,7 +54,7 @@ import org.opengroup.osdu.core.common.model.indexer.OperationType;
import org.opengroup.osdu.core.common.search.ElasticIndexNameResolver;
import org.opengroup.osdu.core.common.search.IndicesService;
import org.opengroup.osdu.indexer.provider.interfaces.ISchemaCache;
import org.opengroup.osdu.indexer.service.impl.SchemaProviderImpl;
import org.opengroup.osdu.indexer.service.SchemaProviderImpl;
import org.opengroup.osdu.indexer.util.ElasticClientHandler;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.springframework.test.context.junit4.SpringRunner;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment