##### Coverage Report - com.ctrip.framework.apollo.portal.util.RequestPrecondition

Classes in this File | Line Coverage | Branch Coverage | Complexity
RequestPrecondition |
60% | 6/10
50% | 2/4
| 1.6666666666666667;1.667

1 |  |
     package com.ctrip.framework.apollo.portal.util;
2 |  |
3 |  |
4 |  |
     import com.ctrip.framework.apollo.core.exception.BadRequestException;
5 |  |
     import com.ctrip.framework.apollo.core.utils.StringUtils;
6 |  |
7 | 0 |
     public class RequestPrecondition {
8 |  |
9 | 1 |
       private static String CONTAIN_EMPTY_ARGUMENT = "request payload should not be contain empty.";
10 |  |
11 | 1 |
       private static String ILLEGAL_MODEL = "request model is invalid";
12 |  |
13 |  |
       public static void checkArgument(String... args) {
14 | 1 |
         checkArgument(!StringUtils.isContainEmpty(args), CONTAIN_EMPTY_ARGUMENT);
15 | 1 |
       }
16 |  |
17 |  |
       public static void checkModel(boolean valid){
18 | 0 |
         checkArgument(valid, ILLEGAL_MODEL);
19 | 0 |
       }
20 |  |
21 |  |
       public static void checkArgument(boolean expression, Object errorMessage) {
22 | 1 |
         if (!expression) {
23 | 0 |
           throw new BadRequestException(String.valueOf(errorMessage));
24 |  |
         }
25 | 1 |
       }
26 |  |
27 |  |
28 |  |
29 |  |
     }