5959import static org .assertj .core .api .Assertions .assertThat ;
6060
6161/**
62- *
6362 * @author Shawn Deng
64- * @date 2021-02-24 16:36:26
6563 */
6664@ TestMethodOrder (OrderAnnotation .class )
6765public class RecordOperationTest {
@@ -92,7 +90,7 @@ void testCreateRecordByNameFromFile() throws IOException, ApiException {
9290 assertThat (inputStream ).isNotNull ();
9391 List <RecordMap > recordMaps = JacksonJsonUtil .unmarshalInputStreamToList (RecordMap .class , inputStream );
9492 CreateRecordRequest recordRequest = new CreateRecordRequest ()
95- .withRecords (recordMaps );
93+ .withRecords (recordMaps );
9694 List <Record > newRecords = vikaApiClient .getRecordApi ().addRecords (DATASHEET_ID , recordRequest );
9795 assertThat (newRecords ).isNotNull ();
9896 assertThat (newRecords ).isNotEmpty ();
@@ -119,8 +117,8 @@ void testCreateRecordByIdFromFile() throws IOException, ApiException {
119117 assertThat (inputStream ).isNotNull ();
120118 List <RecordMap > recordMaps = JacksonJsonUtil .unmarshalInputStreamToList (RecordMap .class , inputStream );
121119 CreateRecordRequest recordRequest = new CreateRecordRequest ()
122- .withRecords (recordMaps )
123- .withFieldKey (FieldKey .ID );
120+ .withRecords (recordMaps )
121+ .withFieldKey (FieldKey .ID );
124122 List <Record > newRecords = vikaApiClient .getRecordApi ().addRecords (DATASHEET_ID , recordRequest );
125123 assertThat (newRecords ).isNotNull ();
126124 assertThat (newRecords ).isNotEmpty ();
@@ -143,16 +141,16 @@ void testCreateRecordByIdFromFile() throws IOException, ApiException {
143141 @ Order (20 )
144142 void testCreateRecordFromJson () throws IOException , ApiException {
145143 ObjectNode fieldMap = JsonNodeFactory .instance .objectNode ()
146- .put ("ShortText" , "Json manual builder" )
147- .put ("LongText" , "Json manual builder" )
148- .set ("Options" , JsonNodeFactory .instance .arrayNode ().add ("A" ));
144+ .put ("ShortText" , "Json manual builder" )
145+ .put ("LongText" , "Json manual builder" )
146+ .set ("Options" , JsonNodeFactory .instance .arrayNode ().add ("A" ));
149147 fieldMap .set ("Options" , JsonNodeFactory .instance .arrayNode ().add ("A" ));
150148 fieldMap .set ("MultiSelect" , JsonNodeFactory .instance .arrayNode ().add ("GG" ));
151149 ObjectNode fields = JsonNodeFactory .instance .objectNode ().set ("fields" , fieldMap );
152150 ArrayNode arrayNode = JsonNodeFactory .instance .arrayNode ().add (fields );
153151 List <RecordMap > recordMaps = JacksonJsonUtil .unmarshalJsonNodeToList (RecordMap .class , arrayNode );
154152 CreateRecordRequest recordRequest = new CreateRecordRequest ()
155- .withRecords (recordMaps );
153+ .withRecords (recordMaps );
156154 List <Record > newRecords = vikaApiClient .getRecordApi ().addRecords (DATASHEET_ID , recordRequest );
157155 assertThat (newRecords ).isNotNull ();
158156 assertThat (newRecords ).isNotEmpty ();
@@ -182,7 +180,7 @@ void testCreateRecordFromBean() throws ApiException {
182180
183181 List <RecordMap > recordMaps = Collections .singletonList (new RecordMap ().withFields (JacksonConverter .toMap (fieldDTO )));
184182 CreateRecordRequest recordRequest = new CreateRecordRequest ()
185- .withRecords (recordMaps );
183+ .withRecords (recordMaps );
186184 List <Record > newRecords = vikaApiClient .getRecordApi ().addRecords (DATASHEET_ID , recordRequest );
187185 assertThat (newRecords ).isNotNull ();
188186 assertThat (newRecords ).isNotEmpty ();
@@ -209,7 +207,7 @@ void testUpdateRecord() throws IOException, ApiException {
209207 assertThat (inputStream ).isNotNull ();
210208 List <RecordMap > recordMaps = JacksonJsonUtil .unmarshalInputStreamToList (RecordMap .class , inputStream );
211209 CreateRecordRequest createRecordRequest = new CreateRecordRequest ()
212- .withRecords (recordMaps );
210+ .withRecords (recordMaps );
213211 List <Record > newRecords = vikaApiClient .getRecordApi ().addRecords (DATASHEET_ID , createRecordRequest );
214212 assertThat (newRecords ).isNotNull ();
215213 assertThat (newRecords ).isNotEmpty ();
@@ -221,14 +219,14 @@ void testUpdateRecord() throws IOException, ApiException {
221219 String recordId = recordResult .getRecordId ();
222220
223221 UpdateRecord record = new UpdateRecord ()
224- .withRecordId (recordId )
225- .withField ("ShortText" , "Ps: Test Update, content is 'This is from unit Test update record' before" )
226- // select can be set null or empty array if you want to clear field value
227- .withField ("Options" , Collections .emptyList ())
228- .withField ("MultiSelect" , Arrays .asList ("LL" , "NN" ));
222+ .withRecordId (recordId )
223+ .withField ("ShortText" , "Ps: Test Update, content is 'This is from unit Test update record' before" )
224+ // select can be set null or empty array if you want to clear field value
225+ .withField ("Options" , Collections .emptyList ())
226+ .withField ("MultiSelect" , Arrays .asList ("LL" , "NN" ));
229227
230228 UpdateRecordRequest updateRecordRequest = new UpdateRecordRequest ()
231- .withRecords (Collections .singletonList (record ));
229+ .withRecords (Collections .singletonList (record ));
232230
233231 List <Record > updateRecords = vikaApiClient .getRecordApi ().updateRecords (DATASHEET_ID , updateRecordRequest );
234232 assertThat (updateRecords ).isNotNull ();
@@ -252,8 +250,8 @@ void testUpdateRecordByFieldId() throws IOException, ApiException {
252250 assertThat (inputStream ).isNotNull ();
253251 List <RecordMap > recordMaps = JacksonJsonUtil .unmarshalInputStreamToList (RecordMap .class , inputStream );
254252 CreateRecordRequest createRecordRequest = new CreateRecordRequest ()
255- .withRecords (recordMaps )
256- .withFieldKey (FieldKey .ID );
253+ .withRecords (recordMaps )
254+ .withFieldKey (FieldKey .ID );
257255 List <Record > newRecords = vikaApiClient .getRecordApi ().addRecords (DATASHEET_ID , createRecordRequest );
258256 assertThat (newRecords ).isNotNull ();
259257 assertThat (newRecords ).isNotEmpty ();
@@ -265,15 +263,15 @@ void testUpdateRecordByFieldId() throws IOException, ApiException {
265263 String recordId = recordResult .getRecordId ();
266264
267265 UpdateRecord record = new UpdateRecord ()
268- .withRecordId (recordId )
269- .withField ("fldjoQSlHfV2z" , "Ps: Test Update, content is 'This is from unit Test update record' before" )
270- // select can be set null or empty array if you want to clear field value
271- .withField ("fldAY9mW7MUdW" , Collections .emptyList ())
272- .withField ("fld8w4C5fwDBl" , Arrays .asList ("LL" , "NN" ));
266+ .withRecordId (recordId )
267+ .withField ("fldjoQSlHfV2z" , "Ps: Test Update, content is 'This is from unit Test update record' before" )
268+ // select can be set null or empty array if you want to clear field value
269+ .withField ("fldAY9mW7MUdW" , Collections .emptyList ())
270+ .withField ("fld8w4C5fwDBl" , Arrays .asList ("LL" , "NN" ));
273271
274272 UpdateRecordRequest updateRecordRequest = new UpdateRecordRequest ()
275- .withRecords (Collections .singletonList (record ))
276- .withFieldKey (FieldKey .ID );
273+ .withRecords (Collections .singletonList (record ))
274+ .withFieldKey (FieldKey .ID );
277275
278276 List <Record > updateRecords = vikaApiClient .getRecordApi ().updateRecords (DATASHEET_ID , updateRecordRequest );
279277 assertThat (updateRecords ).isNotNull ();
@@ -297,7 +295,7 @@ void testDeleteRecord() throws IOException, ApiException {
297295 assertThat (inputStream ).isNotNull ();
298296 List <RecordMap > recordMaps = JacksonJsonUtil .unmarshalInputStreamToList (RecordMap .class , inputStream );
299297 CreateRecordRequest createRecordRequest = new CreateRecordRequest ()
300- .withRecords (recordMaps );
298+ .withRecords (recordMaps );
301299 List <Record > newRecords = vikaApiClient .getRecordApi ().addRecords (DATASHEET_ID , createRecordRequest );
302300 assertThat (newRecords ).isNotNull ();
303301 assertThat (newRecords ).isNotEmpty ();
@@ -311,7 +309,7 @@ void testDeleteRecord() throws IOException, ApiException {
311309 vikaApiClient .getRecordApi ().deleteRecord (DATASHEET_ID , recordId );
312310
313311 // assert query whether record exist
314- ApiQueryParam queryParam = ApiQueryParam .EMPTY .withRecordIds (Collections .singletonList (recordId ));
312+ ApiQueryParam queryParam = ApiQueryParam .newInstance () .withRecordIds (Collections .singletonList (recordId ));
315313 Pager <Record > pager = vikaApiClient .getRecordApi ().getRecords (DATASHEET_ID , queryParam );
316314 assertThat (pager ).isNotNull ();
317315 assertThat (pager .getTotalItems ()).isZero ();
@@ -337,7 +335,7 @@ void testDeleteRecordBatch() throws IOException, ApiException {
337335 vikaApiClient .getRecordApi ().deleteRecords (DATASHEET_ID , recordIds );
338336
339337 // assert query whether record exist
340- ApiQueryParam queryParam = ApiQueryParam .EMPTY .withRecordIds (recordIds );
338+ ApiQueryParam queryParam = ApiQueryParam .newInstance () .withRecordIds (recordIds );
341339 Pager <Record > pager = vikaApiClient .getRecordApi ().getRecords (DATASHEET_ID , queryParam );
342340 assertThat (pager ).isNotNull ();
343341 assertThat (pager .getTotalItems ()).isZero ();
0 commit comments