|
24 | 24 | import io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidationv2.IngestionResult;
|
25 | 25 | import io.hops.hopsworks.persistence.entity.featurestore.featuregroup.datavalidationv2.ValidationReport;
|
26 | 26 |
|
| 27 | +import org.json.JSONArray; |
| 28 | +import org.json.JSONObject; |
27 | 29 | import org.junit.Before;
|
28 | 30 | import org.junit.Test;
|
29 | 31 | import java.util.Date;
|
30 | 32 |
|
| 33 | +import static io.hops.hopsworks.common.featurestore.FeaturestoreConstants.PARTIAL_UNEXPECTED_LIST_KEY; |
31 | 34 | import static org.junit.Assert.assertEquals;
|
32 | 35 | import static org.junit.Assert.assertThrows;
|
33 | 36 |
|
@@ -161,4 +164,25 @@ public void testVerifyValidationResultResult() {
|
161 | 164 |
|
162 | 165 | // Long input is silently caught and result is truncated for result field.
|
163 | 166 | }
|
| 167 | + |
| 168 | + @Test |
| 169 | + public void testValidationResultShortenResultField_HandlePartialUnexpectedList(){ |
| 170 | + String result = "{" + |
| 171 | + " \"element_count\": 1,\n" + |
| 172 | + " \"missing_count\": 0,\n" + |
| 173 | + " \"missing_percent\": 0.0,\n" + |
| 174 | + " \"unexpected_count\": 1,\n" + |
| 175 | + " \"unexpected_percent\": 100.0,\n" + |
| 176 | + " \"unexpected_percent_total\": 100.0,\n" + |
| 177 | + " \"unexpected_percent_nonmissing\": 100.0,\n" + |
| 178 | + " \"partial_unexpected_list\": [\n" + |
| 179 | + " \"wrong string\"\n" + |
| 180 | + " ]}"; |
| 181 | + String shortenResultField = validationResultController.validationResultShortenResultField(result); |
| 182 | + JSONObject resultFieldJSON = new JSONObject(shortenResultField); |
| 183 | + |
| 184 | + JSONArray partialUnexpectedList = resultFieldJSON.getJSONArray(PARTIAL_UNEXPECTED_LIST_KEY); |
| 185 | + assertEquals("wrong string", partialUnexpectedList.get(0)); |
| 186 | + } |
| 187 | + |
164 | 188 | }
|
0 commit comments