@@ -1203,30 +1203,39 @@ void increment_should_work() throws Exception {
12031203
12041204
12051205 try {
1206- var data1 = Map .of ("id" , id , "name" , "John" , "contents" , Map .of ("age" , 20 ), "score" , 85.5 );
1206+ var data1 = Map .of ("id" , id , "name" , "John" , "contents" , Map .of ("age" , 20 ), "score" , 85.5 , "number" , 3_147_483_647L );
12071207 db .upsert (coll , data1 , partition ).toMap ();
12081208 {
1209- // increment by 1
1209+ // increment by 1, integer field
12101210 var inc1 = db .increment (coll , id , "/contents/age" , 1 , partition ).toMap ();
12111211 assertThat ((Map <String , Object >) inc1 .get ("contents" )).containsEntry ("age" , 21 );
12121212
1213- // increment by -3
1213+ // increment by -3, integer field
12141214 var inc2 = db .increment (coll , id , "/contents/age" , -3 , partition ).toMap ();
12151215 assertThat ((Map <String , Object >) inc2 .get ("contents" )).containsEntry ("age" , 18 );
1216+
1217+ // increment by 1, long field
1218+ var inc3 = db .increment (coll , id , "/number" , 1 , partition ).toMap ();
1219+ assertThat (inc3 ).containsEntry ("number" , 3_147_483_648L );
1220+
1221+ // increment by 5, double field
1222+ var inc4 = db .increment (coll , id , "/score" , 5 , partition ).toMap ();
1223+ assertThat (inc4 ).containsEntry ("score" , 90.5 );
1224+
12161225 }
12171226
12181227 {
12191228 // failed when incrementing a string field
12201229 assertThatThrownBy (() -> {
1221- db .increment (coll , id , "name" , 5 , partition );
1230+ db .increment (coll , id , "/ name" , 5 , partition );
12221231 }).isInstanceOfSatisfying (CosmosException .class , (e ) -> {
12231232 assertThat (e .getStatusCode ()).isEqualTo (400 );
1224- assertThat (e .getMessage ()).contains ("inputs is invalid " );
1233+ assertThat (e .getMessage ()).contains ("is not a number " );
12251234 });
12261235 }
12271236
12281237 {
1229- // failed when incrementing a double field
1238+ // 400 will be thrown when path is not correct
12301239 assertThatThrownBy (() -> {
12311240 db .increment (coll , id , "score" , 5 , partition );
12321241 }).isInstanceOfSatisfying (CosmosException .class , (e ) -> {
@@ -1235,6 +1244,16 @@ void increment_should_work() throws Exception {
12351244 });
12361245 }
12371246
1247+ {
1248+ // 404 will be thrown when incrementing a not existing item
1249+ assertThatThrownBy (() -> {
1250+ db .increment (coll , "not exist" , "/number" , 1 , partition );
1251+ }).isInstanceOfSatisfying (CosmosException .class , (e ) -> {
1252+ assertThat (e .getStatusCode ()).isEqualTo (404 );
1253+ assertThat (e .getMessage ()).contains ("Not Found" );
1254+ });
1255+ }
1256+
12381257 } finally {
12391258 db .delete (coll , id , partition );
12401259 }
0 commit comments