Skip to content

Commit eb6d1b6

Browse files
committed
HTTP-99 address review feedback
Signed-off-by: davidradl <david_radley@uk.ibm.com>
1 parent 4db1a7b commit eb6d1b6

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/test/java/com/getindata/connectors/http/internal/table/lookup/querycreators/GenericJsonAndUrlQueryCreatorFactoryTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ public void lookupQueryInfoTestStr() {
5050
+ "= false` "
5151
+ "was called before this test execution.")
5252
.isFalse();
53-
53+
// GIVEN
5454
this.config.setString("lookup-request.format", CustomJsonFormatFactory.IDENTIFIER);
5555
this.config.setString(
5656
String.format("lookup-request.format.%s.%s", CustomJsonFormatFactory.IDENTIFIER,
5757
CustomJsonFormatFactory.REQUIRED_OPTION), "optionValue");
5858
this.config.set(REQUEST_QUERY_PARAM_FIELDS, List.of("key1"));
59+
// WHEN/THEN
5960
// with sync
6061
createUsingFactory(false);
6162
// with async
@@ -64,8 +65,10 @@ public void lookupQueryInfoTestStr() {
6465

6566
@Test
6667
public void lookupQueryInfoTestRequiredConfig() {
68+
//GIVEN
6769
GenericJsonAndUrlQueryCreatorFactory genericJsonAndUrlQueryCreatorFactory =
6870
new GenericJsonAndUrlQueryCreatorFactory();
71+
// WHEN/THEN
6972
assertThrows(RuntimeException.class, () -> {
7073
genericJsonAndUrlQueryCreatorFactory.createLookupQueryCreator(config,
7174
null,
@@ -74,6 +77,7 @@ public void lookupQueryInfoTestRequiredConfig() {
7477
}
7578

7679
private void createUsingFactory(boolean async) {
80+
// GIVEN
7781
this.config.setBoolean(HttpLookupConnectorOptions.ASYNC_POLLING, async);
7882
LookupRow lookupRow= new LookupRow()
7983
.addLookupEntry(
@@ -95,7 +99,7 @@ private void createUsingFactory(boolean async) {
9599
GenericRowData lookupRowData = GenericRowData.of(
96100
StringData.fromString("val1")
97101
);
98-
102+
// WHEN/THEN
99103
LookupQueryInfo lookupQueryInfo = lookupQueryCreator.createLookupQuery(lookupRowData);
100104
assertThat(CustomJsonFormatFactory.requiredOptionsWereUsed).isTrue();
101105
assertThat(lookupQueryInfo.hasLookupQuery()).isTrue();
@@ -104,7 +108,9 @@ private void createUsingFactory(boolean async) {
104108
}
105109
@Test
106110
void optionsTests() {
111+
// GIVEN
107112
GenericJsonAndUrlQueryCreatorFactory factory = new GenericJsonAndUrlQueryCreatorFactory();
113+
// WHEN/THEN
108114
assertThat(factory.requiredOptions()).isEmpty();
109115
assertThat(factory.optionalOptions()).contains(REQUEST_QUERY_PARAM_FIELDS);
110116
assertThat(factory.optionalOptions()).contains(REQUEST_BODY_FIELDS);

src/test/java/com/getindata/connectors/http/internal/table/lookup/querycreators/GenericJsonAndUrlQueryCreatorTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void createLookupQueryTestStrAllOps(String operation) {
6464
resolvedSchema)
6565
);
6666
var createdQuery = universalJsonQueryCreator.createLookupQuery(ROWDATA);
67-
// THEN
67+
// WHEN/THEN
6868
if (operation.equals("GET")) {
6969
validateCreatedQueryForGet(createdQuery);
7070
} else {
@@ -126,6 +126,7 @@ private static void validateCreatedQueryForPutAndPost(LookupQueryInfo createdQue
126126

127127
@Test
128128
public void createLookupQueryTest() {
129+
// GIVEN
129130
List<String> query_params = List.of("key1", "key2");
130131
String operation = "GET";
131132
final String key1 = "key1";
@@ -147,18 +148,16 @@ public void createLookupQueryTest() {
147148
DataType dataType = row(List.of(
148149
DataTypes.FIELD(key1, DataTypes.STRING()),
149150
DataTypes.FIELD(key2, DataTypes.STRING())
150-
));;
151+
));
151152
ResolvedSchema resolvedSchema = ResolvedSchema.of(
152153
Column.physical(key1, DataTypes.STRING()),
153154
Column.physical(key2, DataTypes.STRING()));
154155
Configuration config = new Configuration();
155156
config.set(GenericJsonAndUrlQueryCreatorFactory.REQUEST_QUERY_PARAM_FIELDS, query_params);
156157
config.set(GenericJsonAndUrlQueryCreatorFactory.REQUEST_URL_MAP, url_params);
157158
config.setString(LOOKUP_METHOD, operation);
158-
// GIVEN
159-
160159
lookupRow.setLookupPhysicalRowDataType(dataType);
161-
160+
// WHEN
162161
GenericJsonAndUrlQueryCreator genericJsonAndUrlQueryCreator =
163162
(GenericJsonAndUrlQueryCreator) new GenericJsonAndUrlQueryCreatorFactory()
164163
.createLookupQueryCreator(

0 commit comments

Comments
 (0)