Skip to content

Commit

Permalink
Added test cases and withJson for important request classes
Browse files Browse the repository at this point in the history
Signed-off-by: Jai2305 <[email protected]>
  • Loading branch information
Jai2305 committed Sep 1, 2024
1 parent 94a080e commit c101485
Show file tree
Hide file tree
Showing 18 changed files with 293 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface PlainDeserializable<B> {
/** Updates object with newly provided JSON properties
@param parser the JsonParser parser
@param mapper the JsonpMapper mapper used to deserialize values
@return object
@return this object
**/

default B withJson(JsonParser parser, JsonpMapper mapper) {
Expand All @@ -38,7 +38,8 @@ default B withJson(JsonParser parser, JsonpMapper mapper) {
* **/
default B withJson(InputStream inputStream) {
JsonpMapper defaultMapper = JsonpUtils.DEFAULT_JSONP_MAPPER;
return withJson(defaultMapper.jsonProvider().createParser(inputStream), defaultMapper);
JsonParser parser = defaultMapper.jsonProvider().createParser(inputStream);
return withJson(parser, defaultMapper);
}

/** Updates object with newly provided JSON properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
import java.util.Map;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.transport.Endpoint;
Expand Down Expand Up @@ -194,7 +189,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
* Builder for {@link AllocationExplainRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<AllocationExplainRequest> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<AllocationExplainRequest>, PlainDeserializable<Builder> {
@Nullable
private String currentNode;

Expand Down Expand Up @@ -285,6 +280,11 @@ public AllocationExplainRequest build() {

return new AllocationExplainRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@
import java.util.Map;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonData;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.opensearch._types.Time;
Expand Down Expand Up @@ -192,7 +186,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
* Builder for {@link PutClusterSettingsRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<PutClusterSettingsRequest> {
public static class Builder extends ObjectBuilderBase
implements
ObjectBuilder<PutClusterSettingsRequest>,
PlainDeserializable<Builder> {
@Nullable
private Boolean flatSettings;

Expand Down Expand Up @@ -330,6 +327,11 @@ public PutClusterSettingsRequest build() {

return new PutClusterSettingsRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@
import java.util.Map;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonData;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.opensearch._types.Time;
Expand Down Expand Up @@ -259,7 +253,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
* Builder for {@link PutComponentTemplateRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<PutComponentTemplateRequest> {
public static class Builder extends ObjectBuilderBase
implements
ObjectBuilder<PutComponentTemplateRequest>,
PlainDeserializable<Builder> {
@Nullable
private Map<String, JsonData> meta;

Expand Down Expand Up @@ -463,6 +460,11 @@ public PutComponentTemplateRequest build() {

return new PutComponentTemplateRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.opensearch._types.Time;
Expand Down Expand Up @@ -220,7 +215,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
* Builder for {@link RerouteRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<RerouteRequest> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<RerouteRequest>, PlainDeserializable<Builder> {
@Nullable
private List<Command> commands;

Expand Down Expand Up @@ -414,6 +409,11 @@ public RerouteRequest build() {

return new RerouteRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
import java.util.List;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.transport.Endpoint;
Expand Down Expand Up @@ -114,7 +109,7 @@ public Builder toBuilder() {
* Builder for {@link ClearScrollRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<ClearScrollRequest> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<ClearScrollRequest>, PlainDeserializable<Builder> {
@Nullable
private List<String> scrollId;

Expand Down Expand Up @@ -149,6 +144,11 @@ public ClearScrollRequest build() {

return new ClearScrollRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,8 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch._types.Conflicts;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.ExpandWildcard;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.opensearch._types.SearchType;
import org.opensearch.client.opensearch._types.SlicedScroll;
import org.opensearch.client.opensearch._types.Time;
import org.opensearch.client.opensearch._types.WaitForActiveShards;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.*;
import org.opensearch.client.opensearch._types.query_dsl.Operator;
import org.opensearch.client.opensearch._types.query_dsl.Query;
import org.opensearch.client.opensearch.core.search.SourceConfigParam;
Expand Down Expand Up @@ -661,7 +649,7 @@ public Builder toBuilder() {
* Builder for {@link DeleteByQueryRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<DeleteByQueryRequest> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<DeleteByQueryRequest>, PlainDeserializable<Builder> {
@Nullable
private SourceConfigParam source;

Expand Down Expand Up @@ -1306,6 +1294,11 @@ public DeleteByQueryRequest build() {

return new DeleteByQueryRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.opensearch._types.query_dsl.Operator;
Expand Down Expand Up @@ -320,7 +315,7 @@ public Builder toBuilder() {
* Builder for {@link ExplainRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<ExplainRequest> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<ExplainRequest>, PlainDeserializable<Builder> {
@Nullable
private SourceConfigParam source;

Expand Down Expand Up @@ -586,6 +581,11 @@ public ExplainRequest build() {

return new ExplainRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,7 @@
import java.util.Map;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.opensearch._types.StoredScript;
Expand Down Expand Up @@ -183,7 +178,7 @@ public Builder toBuilder() {
* Builder for {@link PutScriptRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<PutScriptRequest> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<PutScriptRequest>, PlainDeserializable<Builder> {
@Nullable
private String context;

Expand Down Expand Up @@ -306,6 +301,11 @@ public PutScriptRequest build() {

return new PutScriptRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,8 @@
import java.util.Map;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.opensearch._types.Conflicts;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.opensearch._types.Script;
import org.opensearch.client.opensearch._types.Time;
import org.opensearch.client.opensearch._types.WaitForActiveShards;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.*;
import org.opensearch.client.opensearch.core.reindex.Destination;
import org.opensearch.client.opensearch.core.reindex.Source;
import org.opensearch.client.transport.Endpoint;
Expand Down Expand Up @@ -332,7 +322,7 @@ public Builder toBuilder() {
* Builder for {@link ReindexRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<ReindexRequest> {
public static class Builder extends ObjectBuilderBase implements ObjectBuilder<ReindexRequest>, PlainDeserializable<Builder> {
@Nullable
private Conflicts conflicts;

Expand Down Expand Up @@ -572,6 +562,11 @@ public ReindexRequest build() {

return new ReindexRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,7 @@
import java.util.Map;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonData;
import org.opensearch.client.json.JsonpDeserializable;
import org.opensearch.client.json.JsonpDeserializer;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.ObjectBuilderDeserializer;
import org.opensearch.client.json.ObjectDeserializer;
import org.opensearch.client.json.PlainJsonSerializable;
import org.opensearch.client.json.*;
import org.opensearch.client.opensearch._types.ErrorResponse;
import org.opensearch.client.opensearch._types.RequestBase;
import org.opensearch.client.transport.Endpoint;
Expand Down Expand Up @@ -164,7 +158,10 @@ public Builder toBuilder() {
* Builder for {@link RenderSearchTemplateRequest}.
*/

public static class Builder extends ObjectBuilderBase implements ObjectBuilder<RenderSearchTemplateRequest> {
public static class Builder extends ObjectBuilderBase
implements
ObjectBuilder<RenderSearchTemplateRequest>,
PlainDeserializable<Builder> {
@Nullable
private String file;

Expand Down Expand Up @@ -234,6 +231,11 @@ public RenderSearchTemplateRequest build() {

return new RenderSearchTemplateRequest(this);
}

@Override
public Builder get() {
return this;
}
}

// ---------------------------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit c101485

Please sign in to comment.