Skip to content

Commit

Permalink
Running spotlessApply
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Winkler <cwinkler@integrationmatters.com
Signed-off-by: Christian Winkler <cwinkler@integrationmatters.com>
  • Loading branch information
fs-chris committed Nov 29, 2023
1 parent 39184fa commit d06be14
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,18 @@

package org.opensearch.client.opensearch.core.bulk;

import jakarta.json.stream.JsonGenerator;
import java.util.Arrays;
import java.util.Iterator;
import java.util.function.Function;

import javax.annotation.Nullable;

import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.JsonpSerializer;
import org.opensearch.client.json.NdJsonpSerializable;
import org.opensearch.client.opensearch._types.Script;
import org.opensearch.client.util.ApiTypeHelper;
import org.opensearch.client.util.ObjectBuilder;

import jakarta.json.stream.JsonGenerator;

// typedef: _global.bulk.UpdateOperation

public class UpdateOperation<TDocument> extends BulkOperationBase implements NdJsonpSerializable, BulkOperationVariant {
Expand All @@ -72,8 +69,7 @@ private UpdateOperation(Builder<TDocument> builder) {

}

public static <TDocument> UpdateOperation<TDocument>
of(Function<Builder<TDocument>, ObjectBuilder<UpdateOperation<TDocument>>> fn) {
public static <TDocument> UpdateOperation<TDocument> of(Function<Builder<TDocument>, ObjectBuilder<UpdateOperation<TDocument>>> fn) {
return fn.apply(new Builder<>()).build();
}

Expand Down Expand Up @@ -130,7 +126,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {

public static class Builder<TDocument> extends BulkOperationBase.AbstractBuilder<Builder<TDocument>>
implements
ObjectBuilder<UpdateOperation<TDocument>> {
ObjectBuilder<UpdateOperation<TDocument>> {

private UpdateOperationData<TDocument> data;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@

package org.opensearch.client.opensearch.core.bulk;

import jakarta.json.stream.JsonGenerator;
import javax.annotation.Nullable;

import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.JsonpSerializable;
import org.opensearch.client.json.JsonpSerializer;
import org.opensearch.client.json.JsonpUtils;
import org.opensearch.client.opensearch._types.Script;
import org.opensearch.client.util.ObjectBuilder;

import jakarta.json.stream.JsonGenerator;

public class UpdateOperationData<TDocument> implements JsonpSerializable {
@Nullable
private final TDocument document;
Expand Down Expand Up @@ -96,7 +94,7 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
*/
public static class Builder<TDocument> extends BulkOperationBase.AbstractBuilder<Builder<TDocument>>
implements
ObjectBuilder<UpdateOperationData<TDocument>> {
ObjectBuilder<UpdateOperationData<TDocument>> {

@Nullable
private TDocument document;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public void testBulkUpdateScriptUpsert() throws IOException {
assertTrue(getResponse.found());
assertEquals(1337, getResponse.source().getIntValue());
}

public void testBulkUpdateScriptedUpsertUpdate() throws IOException {
final String id = "777";

Expand All @@ -412,8 +412,11 @@ public void testBulkUpdateScriptedUpsertUpdate() throws IOException {
s -> s.inline(
new InlineScript.Builder().lang("painless")
.source("ctx._source.intValue = ctx?._source?.intValue == null ? 7777 : 9999")
.build()))))
.build();
.build()
)
)
)
).build();

BulkRequest bulkRequest = new BulkRequest.Builder().operations(op).build();
BulkResponse bulkResponse = javaClient().bulk(bulkRequest);
Expand All @@ -439,8 +442,11 @@ public void testBulkUpdateScriptedUpsertInsert() throws IOException {
s -> s.inline(
new InlineScript.Builder().lang("painless")
.source("ctx._source.intValue = ctx?._source?.intValue == null ? 7777 : 9999")
.build()))))
.build();
.build()
)
)
)
).build();

BulkRequest bulkRequest = new BulkRequest.Builder().operations(op).build();
BulkResponse bulkResponse = javaClient().bulk(bulkRequest);
Expand All @@ -462,12 +468,7 @@ public void testBulkUpdateDetectNoop() throws IOException {

assertEquals(Result.Created, javaClient().index(b -> b.index("index").id(id).document(appData)).result());

BulkOperation op = new BulkOperation.Builder().update(
o -> o.index("index")
.id(id)
.detectNoop(true)
.document(appData))
.build();
BulkOperation op = new BulkOperation.Builder().update(o -> o.index("index").id(id).detectNoop(true).document(appData)).build();

BulkRequest bulkRequest = new BulkRequest.Builder().operations(op).build();
BulkResponse bulkResponse = javaClient().bulk(bulkRequest);
Expand All @@ -476,12 +477,7 @@ public void testBulkUpdateDetectNoop() throws IOException {
assertEquals(1, bulkResponse.items().size());
assertEquals(Result.NoOp.jsonValue(), bulkResponse.items().get(0).result());

op = new BulkOperation.Builder().update(
o -> o.index("index")
.id(id)
.detectNoop(false)
.document(appData))
.build();
op = new BulkOperation.Builder().update(o -> o.index("index").id(id).detectNoop(false).document(appData)).build();

bulkRequest = new BulkRequest.Builder().operations(op).build();
bulkResponse = javaClient().bulk(bulkRequest);
Expand Down

0 comments on commit d06be14

Please sign in to comment.