add junit coverage
[so.git] / so-optimization-clients / src / test / java / org / onap / so / client / oof / OofValidatorTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2021 Nokia
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.client.oof;
22
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.LinkedHashMap;
26 import java.util.Map;
27 import org.junit.Test;
28 import org.onap.so.client.exception.BadResponseException;
29
30 public class OofValidatorTest {
31
32     @Test
33     public void validateDemandsResponse_success() throws Exception {
34         Map<String, String> map = new LinkedHashMap<>();
35         map.put("requestStatus", "accepted");
36         new OofValidator().validateDemandsResponse(map);
37     }
38
39     @Test(expected = BadResponseException.class)
40     public void validateDemandsResponse_mapIsEmpty() throws Exception {
41         new OofValidator().validateDemandsResponse(Collections.emptyMap());
42     }
43
44     @Test(expected = BadResponseException.class)
45     public void validateDemandsResponse_lackOfRequestStatus() throws Exception {
46         Map<String, String> map = new LinkedHashMap<>();
47         map.put("a", "a");
48         new OofValidator().validateDemandsResponse(map);
49     }
50
51     @Test(expected = BadResponseException.class)
52     public void validateDemandsResponse_lackOfRequestStatusProperValue() throws Exception {
53         Map<String, String> map = new HashMap<>();
54         map.put("requestStatus", "a");
55         map.put("statusMessage", "a");
56         new OofValidator().validateDemandsResponse(map);
57     }
58 }