deepthi912 commented on code in PR #13296:
URL: https://github.com/apache/pinot/pull/13296#discussion_r1733938729


##########
pinot-spi/src/test/java/org/apache/pinot/spi/data/SchemaInfoTest.java:
##########
@@ -0,0 +1,91 @@
+/**
+ * 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.pinot.spi.data;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.pinot.spi.utils.CommonConstants;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.testng.annotations.Test;
+
+import static org.apache.pinot.spi.data.FieldSpec.DataType.INT;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+
+
+public class SchemaInfoTest {
+
+  @Test
+  public void testSchemaInfoSerDeserWithVirtualColumns()
+      throws IOException {
+    // Mock the Schema object
+    Schema schemaMock = mock(Schema.class);
+    when(schemaMock.getSchemaName()).thenReturn("TestSchema");
+    DimensionFieldSpec dimensionFieldSpec1 = new DimensionFieldSpec("dim1", 
FieldSpec.DataType.STRING, true);
+    DimensionFieldSpec dimensionFieldSpec2 = new DimensionFieldSpec("dim2", 
FieldSpec.DataType.INT, true);
+    DimensionFieldSpec dimensionFieldSpec3 = new DimensionFieldSpec("dim2", 
FieldSpec.DataType.INT, true);
+    DimensionFieldSpec dimensionFieldSpec4 =
+        new 
DimensionFieldSpec(CommonConstants.Segment.BuiltInVirtualColumn.DOCID, 
FieldSpec.DataType.INT, true);
+    DimensionFieldSpec dimensionFieldSpec5 =
+        new 
DimensionFieldSpec(CommonConstants.Segment.BuiltInVirtualColumn.HOSTNAME, 
FieldSpec.DataType.STRING, true);
+    DimensionFieldSpec dimensionFieldSpec6 =
+        new 
DimensionFieldSpec(CommonConstants.Segment.BuiltInVirtualColumn.SEGMENTNAME, 
FieldSpec.DataType.STRING,
+            true);
+    List<DimensionFieldSpec> dimensionFieldSpecs = new ArrayList<>();
+    dimensionFieldSpecs.add(dimensionFieldSpec1);
+    dimensionFieldSpecs.add(dimensionFieldSpec2);
+    dimensionFieldSpecs.add(dimensionFieldSpec3);
+    dimensionFieldSpecs.add(dimensionFieldSpec4);
+    dimensionFieldSpecs.add(dimensionFieldSpec5);
+    dimensionFieldSpecs.add(dimensionFieldSpec6);
+    when(schemaMock.getDimensionFieldSpecs()).thenReturn(dimensionFieldSpecs);
+    DateTimeFieldSpec dateTimeFieldSpec1 =
+        new DateTimeFieldSpec("dt1", FieldSpec.DataType.LONG, "1:HOURS:EPOCH", 
"1:HOURS");
+    DateTimeFieldSpec dateTimeFieldSpec2 =
+        new DateTimeFieldSpec("dt2", FieldSpec.DataType.LONG, "1:HOURS:EPOCH", 
"1:HOURS");
+    List<DateTimeFieldSpec> dateTimeFieldSpecs = new ArrayList<>();
+    dateTimeFieldSpecs.add(dateTimeFieldSpec1);
+    dateTimeFieldSpecs.add(dateTimeFieldSpec2);
+    when(schemaMock.getDateTimeFieldSpecs()).thenReturn(dateTimeFieldSpecs);
+    MetricFieldSpec metricFieldSpec1 = new MetricFieldSpec("metric", INT, -1);
+    List<MetricFieldSpec> metricFieldSpecs = new ArrayList<>();
+    metricFieldSpecs.add(metricFieldSpec1);
+    when(schemaMock.getMetricFieldSpecs()).thenReturn(metricFieldSpecs);
+    SchemaInfo schemaInfo = new SchemaInfo(schemaMock);
+    List<SchemaInfo> schemaInfoList = new ArrayList<>();
+    schemaInfoList.add(schemaInfo);
+    String response = JsonUtils.objectToPrettyString(schemaInfoList);
+    JsonNode jsonNodeResp = JsonUtils.stringToJsonNode(response);

Review Comment:
   Good point, I added no args constructor and tested here



-- 
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: commits-unsubscr...@pinot.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to