This is an automated email from the ASF dual-hosted git repository.
jkevan pushed a commit to branch json-schema-extensions
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/json-schema-extensions by this
push:
new 4ca782c8e code review adjustments
4ca782c8e is described below
commit 4ca782c8ee56dec00291d5a5f4c29d0ec096022c
Author: Kevan <[email protected]>
AuthorDate: Mon May 23 15:31:35 2022 +0200
code review adjustments
---
.../org/apache/unomi/schema/impl/SchemaServiceImpl.java | 13 +++++++------
.../test/java/org/apache/unomi/itests/ContextServletIT.java | 2 +-
.../src/test/java/org/apache/unomi/itests/JSONSchemaIT.java | 4 ++--
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git
a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
index 8dd3507a4..4ae6679f9 100644
---
a/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
+++
b/extensions/json-schema/services/src/main/java/org/apache/unomi/schema/impl/SchemaServiceImpl.java
@@ -81,7 +81,7 @@ public class SchemaServiceImpl implements SchemaService {
jsonNode = objectMapper.readTree(data);
jsonSchema = jsonSchemaFactory.getSchema(new URI(schemaId));
} catch (Exception e) {
- logger.error("Schema validation failed because: {} - Set
SchemaServiceImpl at DEBUG level for more detail ", e.getMessage());
+ logger.error("Schema validation failed because: Error during data
reading and initial schema lookup - Set SchemaServiceImpl at DEBUG level for
more detail ");
logger.debug("full error",e);
return false;
}
@@ -92,7 +92,8 @@ public class SchemaServiceImpl implements SchemaService {
}
if (jsonSchema == null) {
- logger.warn("Schema validation failed because: Schema not found
{}", schemaId);
+ logger.warn("Schema validation failed because: Schema not found -
Set SchemaServiceImpl at DEBUG level for more detail ");
+ logger.warn("Schema not found: {}", schemaId);
return false;
}
@@ -100,8 +101,8 @@ public class SchemaServiceImpl implements SchemaService {
try {
validationMessages = jsonSchema.validate(jsonNode);
} catch (Exception e) {
- logger.error("Schema validation failed because: {} - Set
SchemaServiceImpl at DEBUG level for more detail ", e.getMessage());
- logger.debug("full error",e);
+ logger.error("Schema validation failed because: Error during
validation - Set SchemaServiceImpl at DEBUG level for more detail ");
+ logger.debug("full error", e);
return false;
}
@@ -239,7 +240,7 @@ public class SchemaServiceImpl implements SchemaService {
extensions.putAll(extensionsReloaded);
}
- private String checkForExtensions(String id, String schema) throws
JsonProcessingException {
+ private String generateExtendedSchema(String id, String schema) throws
JsonProcessingException {
Set<String> extensionIds = extensions.get(id);
if (extensionIds != null && extensionIds.size() > 0) {
// This schema need to be extends !
@@ -307,7 +308,7 @@ public class SchemaServiceImpl implements SchemaService {
String schema = jsonSchemaWrapper.getSchema();
// Check if schema need to be extended
- schema = checkForExtensions(schemaId, schema);
+ schema = generateExtendedSchema(schemaId, schema);
return IOUtils.toInputStream(schema);
}, "https", "http")
diff --git a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
index ace2f6e06..90396ea14 100644
--- a/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java
@@ -160,7 +160,7 @@ public class ContextServletIT extends BaseIT {
// cleanup schemas
schemaService.deleteSchema("https://unomi.apache.org/schemas/json/events/testEventType/1-0-0");
schemaService.deleteSchema("https://unomi.apache.org/schemas/json/events/floatPropertyType/1-0-0");
- keepTrying("Couldn't find json schemas",
+ keepTrying("Should not find json schemas anymore",
() -> schemaService.getInstalledJsonSchemaIds(),
(schemaIds) ->
(!schemaIds.contains("https://unomi.apache.org/schemas/json/events/floatPropertyType/1-0-0")
&&
!schemaIds.contains("https://unomi.apache.org/schemas/json/events/testEventType/1-0-0")),
diff --git a/itests/src/test/java/org/apache/unomi/itests/JSONSchemaIT.java
b/itests/src/test/java/org/apache/unomi/itests/JSONSchemaIT.java
index dd31f79ba..d323af407 100644
--- a/itests/src/test/java/org/apache/unomi/itests/JSONSchemaIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/JSONSchemaIT.java
@@ -64,7 +64,7 @@ public class JSONSchemaIT extends BaseIT {
public void tearDown() throws InterruptedException {
removeItems(JsonSchemaWrapper.class, Event.class);
// ensure all schemas have been cleaned from schemaService.
- keepTrying("Couldn't find json schemas",
+ keepTrying("Should not find json schemas anymore",
() -> schemaService.getInstalledJsonSchemaIds(),
(list) ->
(!list.contains("https://unomi.apache.org/schemas/json/events/dummy/1-0-0") &&
!list.contains("https://unomi.apache.org/schemas/json/events/dummy/properties/1-0-0")),
@@ -188,7 +188,7 @@ public class JSONSchemaIT extends BaseIT {
@Test
public void testEndPoint_GetInstalledJsonSchemas() throws
InterruptedException {
List<String> jsonSchemas = get(JSONSCHEMA_URL, List.class);
- assertFalse("JSON schema list should not be empty, it should contains
predefined Unomi schemas", jsonSchemas.isEmpty());
+ assertFalse("JSON schema list should not be empty, it should contain
predefined Unomi schemas", jsonSchemas.isEmpty());
}
@Test