Skip to content

Commit

Permalink
PR review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
antas-marcin committed Oct 25, 2023
1 parent 3388aeb commit 75d8d0a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 44 deletions.
12 changes: 3 additions & 9 deletions src/main/java/io/weaviate/client/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Map;
import lombok.Getter;
import lombok.Setter;

public class Config {

Expand All @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Boolean> createResult = client.schema().classCreator()
.withClass(WeaviateClass.builder()
.className(CLASS_NAME)
.properties(allProperties())
.properties(properties())
.build()
)
.run();
Expand All @@ -795,7 +794,7 @@ private void createAllPropertiesClass(WeaviateClient client) {
.returns(true, Result::getResult);
}

public List<Property> allProperties() {
public List<Property> properties() {
return Arrays.asList(
Property.builder()
.name("bool")
Expand Down Expand Up @@ -862,7 +861,7 @@ public List<Property> allProperties() {
);
}

public List<Property> allPropertiesWithNestedObject() {
public List<Property> propertiesWithNestedObject() {
Property objectProperty = Property.builder()
.name("objectProperty")
.dataType(Collections.singletonList(DataType.OBJECT))
Expand All @@ -874,12 +873,12 @@ public List<Property> allPropertiesWithNestedObject() {
))
.build();
List<Property> props = new ArrayList<>();
props.addAll(allProperties());
props.addAll(properties());
props.add(objectProperty);
return props;
}

public List<Property> allPropertiesWithNestedObjectAndNestedArrayObject() {
public List<Property> propertiesWithNestedObjectAndNestedArrayObject() {
Property objectArrayProperty = Property.builder()
.name("objectArrayProperty")
.dataType(Collections.singletonList(DataType.OBJECT_ARRAY))
Expand All @@ -891,7 +890,7 @@ public List<Property> allPropertiesWithNestedObjectAndNestedArrayObject() {
))
.build();
List<Property> props = new ArrayList<>();
props.addAll(allPropertiesWithNestedObject());
props.addAll(propertiesWithNestedObject());
props.add(objectArrayProperty);
return props;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,23 @@ public void shouldCreateBatchWithNestedObjectAndNestedArrayObjectUsingRest() {
private void testCreateBatch(Boolean useGRPC) {
WeaviateTestGenerics.AllPropertiesSchema testData = new WeaviateTestGenerics.AllPropertiesSchema();
String className = testData.CLASS_NAME;
List<Property> properties = testData.allProperties();
List<Property> properties = testData.properties();
WeaviateObject[] objects = testData.objects();
testCreateBatch(useGRPC, className, properties, objects);
}

private void testCreateBatchWithNested(Boolean useGRPC) {
WeaviateTestGenerics.AllPropertiesSchema testData = new WeaviateTestGenerics.AllPropertiesSchema();
String className = testData.CLASS_NAME;
List<Property> properties = testData.allPropertiesWithNestedObject();
List<Property> properties = testData.propertiesWithNestedObject();
WeaviateObject[] objects = testData.objectsWithNestedObject();
testCreateBatch(useGRPC, className, properties, objects);
}

private void testCreateBatchWithNestedAndNestArrayObject(Boolean useGRPC) {
WeaviateTestGenerics.AllPropertiesSchema testData = new WeaviateTestGenerics.AllPropertiesSchema();
String className = testData.CLASS_NAME;
List<Property> properties = testData.allPropertiesWithNestedObjectAndNestedArrayObject();
List<Property> properties = testData.propertiesWithNestedObjectAndNestedArrayObject();
WeaviateObject[] objects = testData.objectsWithNestedObjectAndNestedArrayObject();
testCreateBatch(useGRPC, className, properties, objects);
}
Expand Down Expand Up @@ -122,7 +122,7 @@ private void testCreateBatch(Boolean useGRPC, String className, List<Property> p

for (WeaviateObject obj : objects) {
Result<List<WeaviateObject>> resultObj = client.data().objectsGetter()
.withID(obj.getId()).withClassName(obj.getTenant())
.withID(obj.getId()).withClassName(obj.getClassName())
.run();
assertThat(resultObj).isNotNull()
.returns(false, Result::hasErrors)
Expand Down
40 changes: 20 additions & 20 deletions src/test/resources/json/nested-array-object.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand All @@ -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
},
Expand Down
4 changes: 2 additions & 2 deletions src/test/resources/json/nested-one-object.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down

0 comments on commit 75d8d0a

Please sign in to comment.