You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ma...@apache.org on 2023/01/09 17:10:26 UTC

[solr] branch main updated: Add a trivial validator for the new CoreAugmenter transformer (#1281)

This is an automated email from the ASF dual-hosted git repository.

magibney pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 3247803ea6e Add a trivial validator for the new CoreAugmenter transformer (#1281)
3247803ea6e is described below

commit 3247803ea6e97b2d735fde08c12057de3c88086c
Author: Michael Gibney <mi...@michaelgibney.net>
AuthorDate: Mon Jan 9 12:10:20 2023 -0500

    Add a trivial validator for the new CoreAugmenter transformer (#1281)
    
    Followup on a2f3f7f33efd765cc6c608c78745d8b9c108b8df
    See: #1276
---
 .../apache/solr/cloud/TestRandomFlRTGCloud.java    | 42 ++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
index 3950de3a43a..e77556936c7 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestRandomFlRTGCloud.java
@@ -103,6 +103,8 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
           new DocIdValidator("my_docid_alias"),
           new ShardValidator(),
           new ShardValidator("my_shard_alias"),
+          new CoreValidator(),
+          new CoreValidator("my_core_alias"),
           new ValueAugmenterValidator(42),
           new ValueAugmenterValidator(1976, "val_alias"),
           //
@@ -1035,6 +1037,46 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
     }
   }
 
+  /** Trivial validator of CoreAugmenterFactory */
+  private static class CoreValidator implements FlValidator {
+    private static final String NAME = "core";
+    private static final String USAGE = "[" + NAME + "]";
+    private final String resultKey;
+
+    public CoreValidator(final String resultKey) {
+      this.resultKey = resultKey;
+    }
+
+    public CoreValidator() {
+      this(USAGE);
+    }
+
+    @Override
+    public String getDefaultTransformerFactoryName() {
+      return NAME;
+    }
+
+    @Override
+    public String getFlParam() {
+      return USAGE.equals(resultKey) ? resultKey : resultKey + ":" + USAGE;
+    }
+
+    @Override
+    public Collection<String> assertRTGResults(
+        final Collection<FlValidator> validators,
+        final SolrInputDocument expected,
+        final SolrDocument actual,
+        final String wt) {
+      final Object value = actual.getFirstValue(resultKey);
+      assertNotNull(getFlParam() + " => no value in actual doc", value);
+      assertTrue(USAGE + " must be a String: " + value, value instanceof String);
+
+      // trivial sanity check
+      assertFalse(USAGE + " => blank string", value.toString().trim().isEmpty());
+      return Collections.singleton(resultKey);
+    }
+  }
+
   /** Trivial validator of ValueAugmenter */
   private static class ValueAugmenterValidator implements FlValidator {
     private static final String NAME = "value";