From 75d8d0a93d9a7e93b8a6c173348e4edca74379f7 Mon Sep 17 00:00:00 2001 From: Marcin Antas Date: Wed, 25 Oct 2023 20:32:54 +0200 Subject: [PATCH] PR review fixes --- src/main/java/io/weaviate/client/Config.java | 12 ++---- .../client/WeaviateTestGenerics.java | 17 ++++---- .../batch/ClientBatchGrpcCreateTest.java | 8 ++-- .../resources/json/nested-array-object.json | 40 +++++++++---------- .../resources/json/nested-one-object.json | 4 +- 5 files changed, 37 insertions(+), 44 deletions(-) diff --git a/src/main/java/io/weaviate/client/Config.java b/src/main/java/io/weaviate/client/Config.java index 6182ee81..43d08002 100644 --- a/src/main/java/io/weaviate/client/Config.java +++ b/src/main/java/io/weaviate/client/Config.java @@ -2,6 +2,7 @@ import java.util.Map; import lombok.Getter; +import lombok.Setter; public class Config { @@ -25,8 +26,9 @@ public class Config { private int proxyPort; @Getter private String proxyScheme; + @Setter private boolean useGRPC; - @Getter + @Getter @Setter private String grpcAddress; public Config(String scheme, String host) { @@ -71,12 +73,4 @@ public void setProxy(String proxyHost, int proxyPort, String proxyScheme) { public boolean useGRPC() { return this.useGRPC; } - - public void setUseGRPC(boolean useGRPC) { - this.useGRPC = useGRPC; - } - - public void setGrpcAddress(String grpcAddress) { - this.grpcAddress = grpcAddress; - } } diff --git a/src/test/java/io/weaviate/integration/client/WeaviateTestGenerics.java b/src/test/java/io/weaviate/integration/client/WeaviateTestGenerics.java index 6754dd05..6f432b99 100644 --- a/src/test/java/io/weaviate/integration/client/WeaviateTestGenerics.java +++ b/src/test/java/io/weaviate/integration/client/WeaviateTestGenerics.java @@ -36,7 +36,6 @@ import org.apache.commons.lang3.time.DateFormatUtils; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.InstanceOfAssertFactories.ARRAY; -import org.jetbrains.annotations.NotNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; @@ -777,15 +776,15 @@ public static class AllPropertiesSchema { public String CLASS_NAME = "AllProperties"; public void createSchemaWithRefClass(WeaviateClient client) { - createAllPropertiesClass(client); + createClass(client); createRefClass(client); } - private void createAllPropertiesClass(WeaviateClient client) { + private void createClass(WeaviateClient client) { Result createResult = client.schema().classCreator() .withClass(WeaviateClass.builder() .className(CLASS_NAME) - .properties(allProperties()) + .properties(properties()) .build() ) .run(); @@ -795,7 +794,7 @@ private void createAllPropertiesClass(WeaviateClient client) { .returns(true, Result::getResult); } - public List allProperties() { + public List properties() { return Arrays.asList( Property.builder() .name("bool") @@ -862,7 +861,7 @@ public List allProperties() { ); } - public List allPropertiesWithNestedObject() { + public List propertiesWithNestedObject() { Property objectProperty = Property.builder() .name("objectProperty") .dataType(Collections.singletonList(DataType.OBJECT)) @@ -874,12 +873,12 @@ public List allPropertiesWithNestedObject() { )) .build(); List props = new ArrayList<>(); - props.addAll(allProperties()); + props.addAll(properties()); props.add(objectProperty); return props; } - public List allPropertiesWithNestedObjectAndNestedArrayObject() { + public List propertiesWithNestedObjectAndNestedArrayObject() { Property objectArrayProperty = Property.builder() .name("objectArrayProperty") .dataType(Collections.singletonList(DataType.OBJECT_ARRAY)) @@ -891,7 +890,7 @@ public List allPropertiesWithNestedObjectAndNestedArrayObject() { )) .build(); List props = new ArrayList<>(); - props.addAll(allPropertiesWithNestedObject()); + props.addAll(propertiesWithNestedObject()); props.add(objectArrayProperty); return props; } diff --git a/src/test/java/io/weaviate/integration/client/batch/ClientBatchGrpcCreateTest.java b/src/test/java/io/weaviate/integration/client/batch/ClientBatchGrpcCreateTest.java index f17b09e3..591fa6ad 100644 --- a/src/test/java/io/weaviate/integration/client/batch/ClientBatchGrpcCreateTest.java +++ b/src/test/java/io/weaviate/integration/client/batch/ClientBatchGrpcCreateTest.java @@ -74,7 +74,7 @@ public void shouldCreateBatchWithNestedObjectAndNestedArrayObjectUsingRest() { private void testCreateBatch(Boolean useGRPC) { WeaviateTestGenerics.AllPropertiesSchema testData = new WeaviateTestGenerics.AllPropertiesSchema(); String className = testData.CLASS_NAME; - List properties = testData.allProperties(); + List properties = testData.properties(); WeaviateObject[] objects = testData.objects(); testCreateBatch(useGRPC, className, properties, objects); } @@ -82,7 +82,7 @@ private void testCreateBatch(Boolean useGRPC) { private void testCreateBatchWithNested(Boolean useGRPC) { WeaviateTestGenerics.AllPropertiesSchema testData = new WeaviateTestGenerics.AllPropertiesSchema(); String className = testData.CLASS_NAME; - List properties = testData.allPropertiesWithNestedObject(); + List properties = testData.propertiesWithNestedObject(); WeaviateObject[] objects = testData.objectsWithNestedObject(); testCreateBatch(useGRPC, className, properties, objects); } @@ -90,7 +90,7 @@ private void testCreateBatchWithNested(Boolean useGRPC) { private void testCreateBatchWithNestedAndNestArrayObject(Boolean useGRPC) { WeaviateTestGenerics.AllPropertiesSchema testData = new WeaviateTestGenerics.AllPropertiesSchema(); String className = testData.CLASS_NAME; - List properties = testData.allPropertiesWithNestedObjectAndNestedArrayObject(); + List properties = testData.propertiesWithNestedObjectAndNestedArrayObject(); WeaviateObject[] objects = testData.objectsWithNestedObjectAndNestedArrayObject(); testCreateBatch(useGRPC, className, properties, objects); } @@ -122,7 +122,7 @@ private void testCreateBatch(Boolean useGRPC, String className, List p for (WeaviateObject obj : objects) { Result> resultObj = client.data().objectsGetter() - .withID(obj.getId()).withClassName(obj.getTenant()) + .withID(obj.getId()).withClassName(obj.getClassName()) .run(); assertThat(resultObj).isNotNull() .returns(false, Result::hasErrors) diff --git a/src/test/resources/json/nested-array-object.json b/src/test/resources/json/nested-array-object.json index de3d02c8..78f09c42 100644 --- a/src/test/resources/json/nested-array-object.json +++ b/src/test/resources/json/nested-array-object.json @@ -4,11 +4,11 @@ "lastName": "Smith", "profession": "Software Engineer", "description": "Experienced software engineer with a passion for coding and problem-solving.", - "phone": { + "phoneAsObject": { "input": "020 1234567", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 4.9 }, @@ -19,11 +19,11 @@ "lastName": "Johnson", "profession": "Graphic Designer", "description": "Creative graphic designer with a strong sense of visual aesthetics.", - "phone": { + "phoneAsObject": { "input": "020 1234599", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 4.19 }, @@ -34,11 +34,11 @@ "lastName": "Williams", "profession": "Accountant", "description": "Detail-oriented accountant with a knack for numbers and financial analysis.", - "phone": { + "phoneAsObject": { "input": "020 1234588", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 4.29 }, @@ -49,11 +49,11 @@ "lastName": "Davis", "profession": "Marketing Manager", "description": "Seasoned marketing manager specializing in digital marketing strategies.", - "phone": { + "phoneAsObject": { "input": "020 1234511", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 4.39 }, @@ -64,11 +64,11 @@ "lastName": "Brown", "profession": "Doctor", "description": "Dedicated medical doctor committed to providing top-quality healthcare.", - "phone": { + "phoneAsObject": { "input": "020 1234111", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 4.49 }, @@ -79,11 +79,11 @@ "lastName": "Miller", "profession": "Teacher", "description": "Passionate teacher with a love for educating and nurturing young minds.", - "phone": { + "phoneAsObject": { "input": "020 1234589", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 4.339 }, @@ -94,11 +94,11 @@ "lastName": "Jones", "profession": "Architect", "description": "Innovative architect known for creating breathtaking and sustainable designs.", - "phone": { + "phoneAsObject": { "input": "020 1234567", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 5.9 }, @@ -109,11 +109,11 @@ "lastName": "Wilson", "profession": "Chef", "description": "Talented chef renowned for crafting exquisite culinary delights.", - "phone": { + "phoneAsObject": { "input": "020 200300300", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 4.9009 }, @@ -124,11 +124,11 @@ "lastName": "Anderson", "profession": "Financial Analyst", "description": "Analytical financial analyst with expertise in investment strategies.", - "phone": { + "phoneAsObject": { "input": "020 1234444", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 6.9 }, @@ -139,11 +139,11 @@ "lastName": "Martin", "profession": "Journalist", "description": "Dedicated journalist with a passion for reporting the truth.", - "phone": { + "phoneAsObject": { "input": "020 1234909", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 44.9 }, diff --git a/src/test/resources/json/nested-one-object.json b/src/test/resources/json/nested-one-object.json index 13422be3..a0d5e014 100644 --- a/src/test/resources/json/nested-one-object.json +++ b/src/test/resources/json/nested-one-object.json @@ -3,11 +3,11 @@ "lastName": "Smith", "profession": "Software Engineer", "description": "Experienced software engineer with a passion for coding and problem-solving.", - "phone": { + "phoneAsObject": { "input": "020 1234567", "defaultCountry": "us" }, - "location": { + "locationAsObject": { "latitude": 52.366667, "longitude": 4.9 },