EndzeitBegins commented on code in PR #9108:
URL: https://github.com/apache/nifi/pull/9108#discussion_r1694245632


##########
nifi-extension-bundles/nifi-extension-utils/nifi-record-utils/nifi-mock-record-utils/src/main/java/org/apache/nifi/serialization/record/MockSchemaRegistry.java:
##########
@@ -33,40 +33,59 @@
 import java.util.concurrent.ConcurrentMap;
 
 public class MockSchemaRegistry extends AbstractControllerService implements 
SchemaRegistry {
-    private final ConcurrentMap<String, RecordSchema> schemaNameMap = new 
ConcurrentHashMap<>();
+    private final ConcurrentMap<Triple<String, String, Integer>, RecordSchema> 
schemaNameMap = new ConcurrentHashMap<>();
     private final ConcurrentMap<Tuple<Long, Integer>, RecordSchema> 
schemaIdVersionMap = new ConcurrentHashMap<>();
 
     public void addSchema(final String name, final RecordSchema schema) {
-        schemaNameMap.put(name, schema);
+        addSchema(name, null, null, schema);
     }
 
-    RecordSchema retrieveSchemaByName(final SchemaIdentifier schemaIdentifier) 
throws IOException, SchemaNotFoundException {
+    public void addSchema(final String name, final String branch, final 
RecordSchema schema) {
+        addSchema(name, branch, null, schema);
+    }
+
+    public void addSchema(final String name, final Integer version, final 
RecordSchema schema) {
+        addSchema(name, null, version, schema);
+    }
+
+    public void addSchema(final String name, final String branch, final 
Integer version, final RecordSchema schema) {
+        schemaNameMap.put(Triple.of(name, branch, version), schema);
+    }
+
+    RecordSchema retrieveSchemaByName(final SchemaIdentifier schemaIdentifier) 
throws SchemaNotFoundException {
         final Optional<String> schemaName = schemaIdentifier.getName();
-        if (!schemaName.isPresent()) {
-            throw new 
org.apache.nifi.schema.access.SchemaNotFoundException("Cannot retrieve schema 
because Schema Name is not present");
+        if (schemaName.isEmpty()) {
+            throw new 
org.apache.nifi.schema.access.SchemaNotFoundException("Cannot retrieve schema 
because Schema Name is empty");

Review Comment:
   I think the refactor to check for `isEmpty()` is easier to read than the 
inverted `isPresent()`., thank you for incorporating that.
   
   However, I wouldn't change the exception message here. To me "is empty" on a 
String type sounds like it was an actual empty String such as `""` instead of a 
value being missing / `null` like here.
   That's for all those places touched in the PR.
   
   



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to