Skip to content

Commit 8cd61aa

Browse files
committed
Fixed test cases
1 parent 54c26ce commit 8cd61aa

File tree

4 files changed

+47
-35
lines changed

4 files changed

+47
-35
lines changed

support/src/main/java/com/shopify/graphql/support/Input.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public static <T> Input<T> value(@Nullable T value) {
2121
}
2222

2323
public static <T> Input<T> undefined() {
24-
return new Input<>(null, true);
24+
return new Input<>(null, false);
2525
}
2626
}

support/src/test/java/com/shopify/graphql/support/Generated.java

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.shopify.graphql.support.Query;
1313
import com.shopify.graphql.support.SchemaViolationError;
1414
import com.shopify.graphql.support.TopLevelResponse;
15+
import com.shopify.graphql.support.Input;
1516

1617
import com.shopify.graphql.support.ID;
1718

@@ -1076,14 +1077,11 @@ public static class SetIntegerInput implements Serializable {
10761077

10771078
private int value;
10781079

1079-
private LocalDateTime ttl;
1080-
private boolean ttlSeen = false;
1080+
private Input<LocalDateTime> ttl = Input.undefined();
10811081

1082-
private Boolean negate;
1083-
private boolean negateSeen = false;
1082+
private Input<Boolean> negate = Input.undefined();
10841083

1085-
private String apiClient;
1086-
private boolean apiClientSeen = false;
1084+
private Input<String> apiClient = Input.undefined();
10871085

10881086
public SetIntegerInput(String key, int value) {
10891087
this.key = key;
@@ -1111,55 +1109,67 @@ public SetIntegerInput setValue(int value) {
11111109

11121110
@Nullable
11131111
public LocalDateTime getTtl() {
1112+
return ttl.value;
1113+
}
1114+
1115+
public Input<LocalDateTime> getTtlInput() {
11141116
return ttl;
11151117
}
11161118

11171119
public SetIntegerInput setTtl(@Nullable LocalDateTime ttl) {
1118-
this.ttl = ttl;
1119-
this.ttlSeen = true;
1120+
this.ttl = Input.value(ttl);
11201121
return this;
11211122
}
11221123

1123-
// Unsets the ttl property so that it is not serialized.
1124-
public SetIntegerInput unsetTtl() {
1125-
this.ttl = null;
1126-
this.ttlSeen = false;
1124+
public SetIntegerInput setTtlInput(@Nullable Input<LocalDateTime> ttl) {
1125+
if (ttl == null) {
1126+
throw new IllegalArgumentException("Input can not be null");
1127+
}
1128+
this.ttl = ttl;
11271129
return this;
11281130
}
11291131

11301132
@Nullable
11311133
public Boolean getNegate() {
1134+
return negate.value;
1135+
}
1136+
1137+
public Input<Boolean> getNegateInput() {
11321138
return negate;
11331139
}
11341140

11351141
public SetIntegerInput setNegate(@Nullable Boolean negate) {
1136-
this.negate = negate;
1137-
this.negateSeen = true;
1142+
this.negate = Input.value(negate);
11381143
return this;
11391144
}
11401145

1141-
// Unsets the negate property so that it is not serialized.
1142-
public SetIntegerInput unsetNegate() {
1143-
this.negate = null;
1144-
this.negateSeen = false;
1146+
public SetIntegerInput setNegateInput(@Nullable Input<Boolean> negate) {
1147+
if (negate == null) {
1148+
throw new IllegalArgumentException("Input can not be null");
1149+
}
1150+
this.negate = negate;
11451151
return this;
11461152
}
11471153

11481154
@Nullable
11491155
public String getApiClient() {
1156+
return apiClient.value;
1157+
}
1158+
1159+
public Input<String> getApiClientInput() {
11501160
return apiClient;
11511161
}
11521162

11531163
public SetIntegerInput setApiClient(@Nullable String apiClient) {
1154-
this.apiClient = apiClient;
1155-
this.apiClientSeen = true;
1164+
this.apiClient = Input.value(apiClient);
11561165
return this;
11571166
}
11581167

1159-
// Unsets the apiClient property so that it is not serialized.
1160-
public SetIntegerInput unsetApiClient() {
1161-
this.apiClient = null;
1162-
this.apiClientSeen = false;
1168+
public SetIntegerInput setApiClientInput(@Nullable Input<String> apiClient) {
1169+
if (apiClient == null) {
1170+
throw new IllegalArgumentException("Input can not be null");
1171+
}
1172+
this.apiClient = apiClient;
11631173
return this;
11641174
}
11651175

@@ -1177,34 +1187,34 @@ public void appendTo(StringBuilder _queryBuilder) {
11771187
_queryBuilder.append("value:");
11781188
_queryBuilder.append(value);
11791189

1180-
if (this.ttlSeen) {
1190+
if (this.ttl.defined || this.ttl.value != null) {
11811191
_queryBuilder.append(separator);
11821192
separator = ",";
11831193
_queryBuilder.append("ttl:");
1184-
if (ttl != null) {
1185-
Query.appendQuotedString(_queryBuilder, ttl.toString());
1194+
if (ttl.value != null) {
1195+
Query.appendQuotedString(_queryBuilder, ttl.value.toString());
11861196
} else {
11871197
_queryBuilder.append("null");
11881198
}
11891199
}
11901200

1191-
if (this.negateSeen) {
1201+
if (this.negate.defined || this.negate.value != null) {
11921202
_queryBuilder.append(separator);
11931203
separator = ",";
11941204
_queryBuilder.append("negate:");
1195-
if (negate != null) {
1196-
_queryBuilder.append(negate);
1205+
if (negate.value != null) {
1206+
_queryBuilder.append(negate.value);
11971207
} else {
11981208
_queryBuilder.append("null");
11991209
}
12001210
}
12011211

1202-
if (this.apiClientSeen) {
1212+
if (this.apiClient.defined || this.apiClient.value != null) {
12031213
_queryBuilder.append(separator);
12041214
separator = ",";
12051215
_queryBuilder.append("api_client:");
1206-
if (apiClient != null) {
1207-
Query.appendQuotedString(_queryBuilder, apiClient.toString());
1216+
if (apiClient.value != null) {
1217+
Query.appendQuotedString(_queryBuilder, apiClient.value.toString());
12081218
} else {
12091219
_queryBuilder.append("null");
12101220
}

support/src/test/java/com/shopify/graphql/support/GeneratedMinimal.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.shopify.graphql.support.Query;
1313
import com.shopify.graphql.support.SchemaViolationError;
1414
import com.shopify.graphql.support.TopLevelResponse;
15+
import com.shopify.graphql.support.Input;
1516

1617
import com.shopify.graphql.support.ID;
1718

support/src/test/java/com/shopify/graphql/support/IntegrationTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.shopify.graphql.support;
22

3+
import java.time.LocalDate;
34
import java.time.LocalDateTime;
45
import java.util.Arrays;
56
import java.util.List;
@@ -168,7 +169,7 @@ public void testOptionalFieldOnInput() throws Exception {
168169
@Test
169170
public void testUnsetOptionalFieldOnInput() throws Exception {
170171
String queryString = Generated.mutation(mutation -> mutation
171-
.setInteger(new Generated.SetIntegerInput("answer", 42).setTtl(null).unsetTtl())
172+
.setInteger(new Generated.SetIntegerInput("answer", 42).setTtlInput(Input.<LocalDateTime>undefined()))
172173
).toString();
173174
assertEquals("mutation{set_integer(input:{key:\"answer\",value:42})}", queryString);
174175
}

0 commit comments

Comments
 (0)