-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add TrainedModelDefinitionDocTests and persist missing field
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...java/org/elasticsearch/xpack/ml/inference/persistence/TrainedModelDefinitionDocTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ml.inference.persistence; | ||
|
||
import org.elasticsearch.common.xcontent.XContentParser; | ||
import org.elasticsearch.test.AbstractXContentTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
public class TrainedModelDefinitionDocTests extends AbstractXContentTestCase<TrainedModelDefinitionDoc> { | ||
|
||
private boolean isLenient = randomBoolean(); | ||
|
||
@Override | ||
protected TrainedModelDefinitionDoc doParseInstance(XContentParser parser) throws IOException { | ||
return TrainedModelDefinitionDoc.fromXContent(parser, isLenient).build(); | ||
} | ||
|
||
@Override | ||
protected boolean supportsUnknownFields() { | ||
return isLenient; | ||
} | ||
|
||
@Override | ||
protected TrainedModelDefinitionDoc createTestInstance() { | ||
int length = randomIntBetween(1, 10); | ||
return new TrainedModelDefinitionDoc.Builder() | ||
.setModelId(randomAlphaOfLength(6)) | ||
.setDefinitionLength(length) | ||
.setTotalDefinitionLength(randomIntBetween(length, length *2)) | ||
.setCompressedString(randomAlphaOfLength(length)) | ||
.setDocNum(randomIntBetween(0, 10)) | ||
.setCompressionVersion(randomIntBetween(1, 5)) | ||
.setEos(randomBoolean()) | ||
.build(); | ||
} | ||
} |