You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by GitBox <gi...@apache.org> on 2022/06/28 13:56:27 UTC

[GitHub] [unomi] jsinovassin opened a new pull request, #449: UNOMI-598 : add keyword to validate scopes

jsinovassin opened a new pull request, #449:
URL: https://github.com/apache/unomi/pull/449

   https://issues.apache.org/jira/browse/UNOMI-598


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [unomi] sergehuber commented on a diff in pull request #449: UNOMI-598 : add keyword to validate scopes

Posted by GitBox <gi...@apache.org>.
sergehuber commented on code in PR #449:
URL: https://github.com/apache/unomi/pull/449#discussion_r909377928


##########
itests/src/test/java/org/apache/unomi/itests/InputValidationIT.java:
##########
@@ -59,6 +64,26 @@ public class InputValidationIT extends BaseIT {
     @Filter(timeout = 600000)
     protected SchemaService schemaService;
 
+    @Inject
+    @Filter(timeout = 600000)
+    protected ScopeService scopeService;
+
+    @Before
+    public void setUp() {
+        Scope scope = new Scope();
+        scope.setItemId("dummy_scope");
+        Metadata metadata = new Metadata();
+        metadata.setName("Dummy scope");
+        metadata.setId("dummy_scope");

Review Comment:
   Same comment here about TestUtils.newScope(String scopeId)



##########
itests/src/test/java/org/apache/unomi/itests/BasicIT.java:
##########
@@ -93,6 +97,27 @@ public class BasicIT extends BaseIT {
     @Inject @Filter(timeout = 600000)
     protected DefinitionsService definitionsService;
 
+    @Inject @Filter(timeout = 600000)
+    protected ScopeService scopeService;
+
+    @Before
+    public void setUp() throws InterruptedException {
+        Scope scope = new Scope();
+        scope.setItemId(TEST_SCOPE);
+        Metadata metadata = new Metadata();
+        metadata.setName("Test scope");
+        metadata.setId(TEST_SCOPE);
+        scope.setMetadata(metadata);

Review Comment:
   Maybe we could refactor this creation to TestUtils.newScope(String scopeId) as we use it multiple times in the tests ? 



##########
itests/src/test/java/org/apache/unomi/itests/JSONSchemaIT.java:
##########
@@ -61,15 +64,27 @@ public class JSONSchemaIT extends BaseIT {
     @Filter(timeout = 600000)
     protected SchemaService schemaService;
 
+    @Inject
+    @Filter(timeout = 6000000)
+    protected ScopeService scopeService;
+
     @Before
     public void setUp() throws InterruptedException {
         keepTrying("Couldn't find json schema endpoint", () -> get(JSONSCHEMA_URL, List.class), Objects::nonNull, DEFAULT_TRYING_TIMEOUT,
                 DEFAULT_TRYING_TRIES);
+
+        Scope scope = new Scope();
+        scope.setItemId("dummy_scope");
+        Metadata metadata = new Metadata();
+        metadata.setName("Dummy scope");
+        metadata.setId("dummy_scope");
+        scope.setMetadata(metadata);

Review Comment:
   Same comment here about TestUtils.newScope(String scopeId)



##########
itests/src/test/java/org/apache/unomi/itests/ContextServletIT.java:
##########
@@ -145,6 +152,16 @@ public void setUp() throws InterruptedException {
                 (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")),
                 DEFAULT_TRYING_TIMEOUT, DEFAULT_TRYING_TRIES);
+
+        Scope scope = new Scope();
+        scope.setItemId(TEST_SCOPE);
+        Metadata metadata = new Metadata();
+        metadata.setName("Test scope");
+        metadata.setId(TEST_SCOPE);
+        scope.setMetadata(metadata);

Review Comment:
   Same comment here about TestUtils.newScope(String scopeId)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [unomi] sergehuber commented on a diff in pull request #449: UNOMI-598 : add keyword to validate scopes

Posted by GitBox <gi...@apache.org>.
sergehuber commented on code in PR #449:
URL: https://github.com/apache/unomi/pull/449#discussion_r908599419


##########
extensions/json-schema/services/src/main/java/org/apache/unomi/schema/keyword/ScopeValidator.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.unomi.schema.keyword;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.networknt.schema.AbstractJsonValidator;
+import com.networknt.schema.CustomErrorMessageType;
+import com.networknt.schema.ValidationMessage;
+import org.apache.unomi.api.services.ScopeService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.MessageFormat;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+public class ScopeValidator extends AbstractJsonValidator {
+    private static final Logger logger = LoggerFactory.getLogger(ScopeValidator.class);
+
+    private ScopeService scopeService;
+
+    public ScopeValidator(ScopeService scopeService) {
+        super("scope");

Review Comment:
   I think it would be clearer if we called it "validateScope", what do you think ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [unomi] jsinovassin merged pull request #449: UNOMI-598 : add keyword to validate scopes

Posted by GitBox <gi...@apache.org>.
jsinovassin merged PR #449:
URL: https://github.com/apache/unomi/pull/449


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@unomi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org