Skip to content

Commit fd15bd2

Browse files
committed
Improve code coverage
1 parent fe9b8c6 commit fd15bd2

File tree

1 file changed

+63
-22
lines changed

1 file changed

+63
-22
lines changed

core/src/main/java/tech/ydb/core/utils/Results.java

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template)
4545
public static <T> T getValueOrThrow(Result<T> result, String template, Object... args)
4646
throws UnexpectedResultException {
4747
if (!result.isSuccess()) {
48-
result.getStatus().expectSuccess(String.format(template, args));
48+
result.getStatus().expectSuccess(
49+
String.format(template, args)
50+
);
4951
}
5052
return result.getValue();
5153
}
@@ -65,7 +67,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, Object...
6567
public static <T> T getValueOrThrow(Result<T> result, String template, int a1)
6668
throws UnexpectedResultException {
6769
if (!result.isSuccess()) {
68-
result.getStatus().expectSuccess(String.format(template, a1));
70+
result.getStatus().expectSuccess(
71+
String.format(template, a1)
72+
);
6973
}
7074
return result.getValue();
7175
}
@@ -85,7 +89,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, int a1)
8589
public static <T> T getValueOrThrow(Result<T> result, String template, long a1)
8690
throws UnexpectedResultException {
8791
if (!result.isSuccess()) {
88-
result.getStatus().expectSuccess(String.format(template, a1));
92+
result.getStatus().expectSuccess(
93+
String.format(template, a1)
94+
);
8995
}
9096
return result.getValue();
9197
}
@@ -105,7 +111,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, long a1)
105111
public static <T> T getValueOrThrow(Result<T> result, String template, boolean a1)
106112
throws UnexpectedResultException {
107113
if (!result.isSuccess()) {
108-
result.getStatus().expectSuccess(String.format(template, a1));
114+
result.getStatus().expectSuccess(
115+
String.format(template, a1)
116+
);
109117
}
110118
return result.getValue();
111119
}
@@ -125,7 +133,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, boolean a
125133
public static <T> T getValueOrThrow(Result<T> result, String template, Object a1)
126134
throws UnexpectedResultException {
127135
if (!result.isSuccess()) {
128-
result.getStatus().expectSuccess(String.format(template, a1));
136+
result.getStatus().expectSuccess(
137+
String.format(template, a1)
138+
);
129139
}
130140
return result.getValue();
131141
}
@@ -146,7 +156,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, Object a1
146156
public static <T> T getValueOrThrow(Result<T> result, String template, int a1, int a2)
147157
throws UnexpectedResultException {
148158
if (!result.isSuccess()) {
149-
result.getStatus().expectSuccess(String.format(template, a1, a2));
159+
result.getStatus().expectSuccess(
160+
String.format(template, a1, a2)
161+
);
150162
}
151163
return result.getValue();
152164
}
@@ -167,7 +179,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, int a1, i
167179
public static <T> T getValueOrThrow(Result<T> result, String template, long a1, int a2)
168180
throws UnexpectedResultException {
169181
if (!result.isSuccess()) {
170-
result.getStatus().expectSuccess(String.format(template, a1, a2));
182+
result.getStatus().expectSuccess(
183+
String.format(template, a1, a2)
184+
);
171185
}
172186
return result.getValue();
173187
}
@@ -188,7 +202,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, long a1,
188202
public static <T> T getValueOrThrow(Result<T> result, String template, boolean a1, int a2)
189203
throws UnexpectedResultException {
190204
if (!result.isSuccess()) {
191-
result.getStatus().expectSuccess(String.format(template, a1, a2));
205+
result.getStatus().expectSuccess(
206+
String.format(template, a1, a2)
207+
);
192208
}
193209
return result.getValue();
194210
}
@@ -209,7 +225,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, boolean a
209225
public static <T> T getValueOrThrow(Result<T> result, String template, Object a1, int a2)
210226
throws UnexpectedResultException {
211227
if (!result.isSuccess()) {
212-
result.getStatus().expectSuccess(String.format(template, a1, a2));
228+
result.getStatus().expectSuccess(
229+
String.format(template, a1, a2)
230+
);
213231
}
214232
return result.getValue();
215233
}
@@ -230,7 +248,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, Object a1
230248
public static <T> T getValueOrThrow(Result<T> result, String template, int a1, long a2)
231249
throws UnexpectedResultException {
232250
if (!result.isSuccess()) {
233-
result.getStatus().expectSuccess(String.format(template, a1, a2));
251+
result.getStatus().expectSuccess(
252+
String.format(template, a1, a2)
253+
);
234254
}
235255
return result.getValue();
236256
}
@@ -251,7 +271,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, int a1, l
251271
public static <T> T getValueOrThrow(Result<T> result, String template, long a1, long a2)
252272
throws UnexpectedResultException {
253273
if (!result.isSuccess()) {
254-
result.getStatus().expectSuccess(String.format(template, a1, a2));
274+
result.getStatus().expectSuccess(
275+
String.format(template, a1, a2)
276+
);
255277
}
256278
return result.getValue();
257279
}
@@ -272,7 +294,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, long a1,
272294
public static <T> T getValueOrThrow(Result<T> result, String template, boolean a1, long a2)
273295
throws UnexpectedResultException {
274296
if (!result.isSuccess()) {
275-
result.getStatus().expectSuccess(String.format(template, a1, a2));
297+
result.getStatus().expectSuccess(
298+
String.format(template, a1, a2)
299+
);
276300
}
277301
return result.getValue();
278302
}
@@ -293,7 +317,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, boolean a
293317
public static <T> T getValueOrThrow(Result<T> result, String template, Object a1, long a2)
294318
throws UnexpectedResultException {
295319
if (!result.isSuccess()) {
296-
result.getStatus().expectSuccess(String.format(template, a1, a2));
320+
result.getStatus().expectSuccess(
321+
String.format(template, a1, a2)
322+
);
297323
}
298324
return result.getValue();
299325
}
@@ -314,7 +340,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, Object a1
314340
public static <T> T getValueOrThrow(Result<T> result, String template, int a1, boolean a2)
315341
throws UnexpectedResultException {
316342
if (!result.isSuccess()) {
317-
result.getStatus().expectSuccess(String.format(template, a1, a2));
343+
result.getStatus().expectSuccess(
344+
String.format(template, a1, a2)
345+
);
318346
}
319347
return result.getValue();
320348
}
@@ -335,7 +363,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, int a1, b
335363
public static <T> T getValueOrThrow(Result<T> result, String template, long a1, boolean a2)
336364
throws UnexpectedResultException {
337365
if (!result.isSuccess()) {
338-
result.getStatus().expectSuccess(String.format(template, a1, a2));
366+
result.getStatus().expectSuccess(
367+
String.format(template, a1, a2)
368+
);
339369
}
340370
return result.getValue();
341371
}
@@ -356,7 +386,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, long a1,
356386
public static <T> T getValueOrThrow(Result<T> result, String template, boolean a1, boolean a2)
357387
throws UnexpectedResultException {
358388
if (!result.isSuccess()) {
359-
result.getStatus().expectSuccess(String.format(template, a1, a2));
389+
result.getStatus().expectSuccess(
390+
String.format(template, a1, a2)
391+
);
360392
}
361393
return result.getValue();
362394
}
@@ -377,7 +409,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, boolean a
377409
public static <T> T getValueOrThrow(Result<T> result, String template, Object a1, boolean a2)
378410
throws UnexpectedResultException {
379411
if (!result.isSuccess()) {
380-
result.getStatus().expectSuccess(String.format(template, a1, a2));
412+
result.getStatus().expectSuccess(
413+
String.format(template, a1, a2)
414+
);
381415
}
382416
return result.getValue();
383417
}
@@ -398,7 +432,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, Object a1
398432
public static <T> T getValueOrThrow(Result<T> result, String template, int a1, Object a2)
399433
throws UnexpectedResultException {
400434
if (!result.isSuccess()) {
401-
result.getStatus().expectSuccess(String.format(template, a1, a2));
435+
result.getStatus().expectSuccess(
436+
String.format(template, a1, a2)
437+
);
402438
}
403439
return result.getValue();
404440
}
@@ -419,7 +455,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, int a1, O
419455
public static <T> T getValueOrThrow(Result<T> result, String template, long a1, Object a2)
420456
throws UnexpectedResultException {
421457
if (!result.isSuccess()) {
422-
result.getStatus().expectSuccess(String.format(template, a1, a2));
458+
result.getStatus().expectSuccess(
459+
String.format(template, a1, a2)
460+
);
423461
}
424462
return result.getValue();
425463
}
@@ -440,14 +478,15 @@ public static <T> T getValueOrThrow(Result<T> result, String template, long a1,
440478
public static <T> T getValueOrThrow(Result<T> result, String template, boolean a1, Object a2)
441479
throws UnexpectedResultException {
442480
if (!result.isSuccess()) {
443-
result.getStatus().expectSuccess(String.format(template, a1, a2));
481+
result.getStatus().expectSuccess(
482+
String.format(template, a1, a2)
483+
);
444484
}
445485
return result.getValue();
446486
}
447487

448488
/**
449489
* Extract a value of the result or throws an exception if the result is unsuccessful.
450-
*
451490
* @param <T> type of the value
452491
* @param result a result
453492
* @param template a template for the exception message to use if the result is unsuccessful;
@@ -461,7 +500,9 @@ public static <T> T getValueOrThrow(Result<T> result, String template, boolean a
461500
public static <T> T getValueOrThrow(Result<T> result, String template, Object a1, Object a2)
462501
throws UnexpectedResultException {
463502
if (!result.isSuccess()) {
464-
result.getStatus().expectSuccess(String.format(template, a1, a2));
503+
result.getStatus().expectSuccess(
504+
String.format(template, a1, a2)
505+
);
465506
}
466507
return result.getValue();
467508
}

0 commit comments

Comments
 (0)