Skip to content

Commit

Permalink
Enabling spotless for rest of the code including tests
Browse files Browse the repository at this point in the history
Signed-off-by: Vacha Shah <[email protected]>
  • Loading branch information
VachaShah committed Oct 4, 2023
1 parent 9e9dac4 commit 56341be
Show file tree
Hide file tree
Showing 82 changed files with 2,714 additions and 3,227 deletions.
2 changes: 1 addition & 1 deletion java-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ tasks.withType<Jar> {
spotless {
java {

target("**/json/**/*.java", "**/transport/**/*.java", "**/util/**/*.java", "**/main/**/opensearch/**/*.java")
target("**/*.java")

// Use the default importOrder configuration
importOrder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@

package org.opensearch.client.documentation;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import org.junit.Assert;
import org.junit.Test;
import org.opensearch.client.opensearch.OpenSearchAsyncClient;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch._types.NodeStatistics;
Expand All @@ -46,15 +54,6 @@
import org.opensearch.client.transport.OpenSearchTransport;
import org.opensearch.client.transport.TransportException;
import org.opensearch.client.util.ApiTypeHelper;
import org.junit.Assert;
import org.junit.Test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.LogManager;
import java.util.logging.Logger;

public class ApiConventionsTest extends Assert {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@

package org.opensearch.client.documentation;

import org.apache.hc.core5.http.HttpHost;
import org.junit.Ignore;
import org.junit.Test;
import org.opensearch.client.RestClient;
import org.opensearch.client.json.jackson.JacksonJsonpMapper;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.opensearch.core.SearchResponse;
import org.opensearch.client.opensearch.core.search.Hit;
import org.opensearch.client.json.jackson.JacksonJsonpMapper;
import org.opensearch.client.transport.OpenSearchTransport;
import org.opensearch.client.transport.rest_client.RestClientTransport;
import org.opensearch.client.RestClient;
import org.apache.hc.core5.http.HttpHost;
import org.junit.Ignore;
import org.junit.Test;

public class ConnectingTest {

private static class Product{}
private static class Product {}

@Ignore // we don't have a running ES
@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,20 @@

package org.opensearch.client.documentation;

import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.jsonb.JsonbJsonpMapper;
import org.opensearch.client.transport.OpenSearchTransport;
import org.opensearch.client.transport.Endpoint;
import org.opensearch.client.transport.TransportException;
import org.opensearch.client.transport.TransportOptions;

import javax.annotation.Nullable;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.opensearch.client.json.JsonpMapper;
import org.opensearch.client.json.jsonb.JsonbJsonpMapper;
import org.opensearch.client.transport.Endpoint;
import org.opensearch.client.transport.OpenSearchTransport;
import org.opensearch.client.transport.TransportException;
import org.opensearch.client.transport.TransportOptions;

/**
* A transport implementation that always fails. Used for simple doc sections where we just want to check compilation.
Expand Down Expand Up @@ -87,8 +86,11 @@ public <RequestT, ResponseT, ErrorT> ResponseT performRequest(
}

@Override
public <RequestT, ResponseT, ErrorT> CompletableFuture<ResponseT> performRequestAsync(RequestT request, Endpoint<RequestT, ResponseT,
ErrorT> endpoint, @Nullable TransportOptions options) {
public <RequestT, ResponseT, ErrorT> CompletableFuture<ResponseT> performRequestAsync(
RequestT request,
Endpoint<RequestT, ResponseT, ErrorT> endpoint,
@Nullable TransportOptions options
) {
CompletableFuture<ResponseT> future = new CompletableFuture<>();
future.completeExceptionally(new TransportException("Not implemented"));
return future;
Expand All @@ -105,6 +107,5 @@ public TransportOptions options() {
}

@Override
public void close() throws IOException {
}
public void close() throws IOException {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,20 @@

package org.opensearch.client.documentation;

import org.opensearch.client.opensearch.OpenSearchClient;
import org.apache.hc.core5.http.HttpHost;
import org.junit.Test;
import org.opensearch.client.RestClient;
import org.opensearch.client.RestClientBuilder;
import org.opensearch.client.json.jackson.JacksonJsonpMapper;
import org.opensearch.client.opensearch.OpenSearchClient;
import org.opensearch.client.transport.OpenSearchTransport;
import org.opensearch.client.transport.rest_client.RestClientTransport;
import org.opensearch.client.RestClient;
import org.opensearch.client.RestClientBuilder;
import org.apache.hc.core5.http.HttpHost;
import org.junit.Test;

public class MigrateHlrcTest {

// Fake HLRC -- we don't want to import it for just one example
public static class RestHighLevelClient {
public RestHighLevelClient(RestClientBuilder builder) {
}
public RestHighLevelClient(RestClientBuilder builder) {}

public RestClient getLowLevelClient() {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,90 +32,65 @@

package org.opensearch.client.opensearch.experiments;

import java.io.IOException;
import java.util.Collections;
import org.junit.Test;
import org.opensearch.client.opensearch.experiments.api.Bar;
import org.opensearch.client.opensearch.experiments.api.FooRequest;
import org.opensearch.client.opensearch.experiments.api.FooResponse;
import org.opensearch.client.opensearch.experiments.api.query2.Query;
import org.opensearch.client.opensearch.experiments.api.query2.TermsQuery;
import org.opensearch.client.opensearch.experiments.base.Client;
import org.opensearch.client.transport.Endpoint;
import org.junit.Test;

import java.io.IOException;
import java.util.Collections;

public class ClientTests {

@Test
public void testClient() throws Exception {
@Test
public void testClient() throws Exception {

Client client = new Client(){
@Override
protected <RequestT, ResponseT, ErrorT> ResponseT performRequest(
RequestT request, Endpoint<RequestT, ResponseT, ErrorT> endpoint
) throws IOException {
// don't care for now, we're testing compilation
return null;
}
};
Client client = new Client() {
@Override
protected <RequestT, ResponseT, ErrorT> ResponseT performRequest(
RequestT request,
Endpoint<RequestT, ResponseT, ErrorT> endpoint
) throws IOException {
// don't care for now, we're testing compilation
return null;
}
};

client.foo(fb -> fb
.name("z")
.value(1)
.routing("fooo")
.query(q -> q
.bool(b-> b
.add_must(m -> m.terms((TermsQuery) null))
)
//.terms(tq -> tq.term(""))
.meta(Collections.emptyMap())
)
);
client.foo(
fb -> fb.name("z")
.value(1)
.routing("fooo")
.query(
q -> q.bool(b -> b.add_must(m -> m.terms((TermsQuery) null)))
// .terms(tq -> tq.term(""))
.meta(Collections.emptyMap())
)
);

// Builders everywhere
FooResponse r1 = client.foo(
FooRequest.builder()
.name("z")
.value(1)
.bar(Bar.builder()
.name("Raise the bar")
.build()
)
.build()
);
// Builders everywhere
FooResponse r1 = client.foo(FooRequest.builder().name("z").value(1).bar(Bar.builder().name("Raise the bar").build()).build());

// Illustrates creating an object outside of the client call
TermsQuery filter = TermsQuery.builder()
.field("foo")
.term("bar")
.build();
// Illustrates creating an object outside of the client call
TermsQuery filter = TermsQuery.builder().field("foo").term("bar").build();

Query filter2 = new Query.Builder()
.terms(t -> t
.field("foo")
.term("bar")
).build();
Query filter2 = new Query.Builder().terms(t -> t.field("foo").term("bar")).build();

// Fluid lambda-based builders
FooResponse r2 = client.foo(f -> f
.name("z")
.value(1)
.bar(bar -> bar
.name("Raise the bar")
)
.query(q -> q
.bool(b -> b
.add_must(q1 -> q1.terms(filter))
.add_must(q1 -> q1
.terms(t -> t.field("a").term("b"))
)
.add_must(q1 -> q1
.terms(t -> t.field("a").term("b"))
)
.minimumShouldMatch(2)
)
)
);
}
// Fluid lambda-based builders
FooResponse r2 = client.foo(
f -> f.name("z")
.value(1)
.bar(bar -> bar.name("Raise the bar"))
.query(
q -> q.bool(
b -> b.add_must(q1 -> q1.terms(filter))
.add_must(q1 -> q1.terms(t -> t.field("a").term("b")))
.add_must(q1 -> q1.terms(t -> t.field("a").term("b")))
.minimumShouldMatch(2)
)
)
);
}
}

Loading

0 comments on commit 56341be

Please sign in to comment.