8e25cc18e0bebaeabc1ecc45de5c22108e6d5b51
[dcaegen2/analytics/tca-gen2.git] / dcae-analytics / dcae-analytics-web / src / test / java / org / onap / dcae / analytics / web / validation / GenericValidationResponseTest.java
1 /*
2  * ================================================================================
3  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
4  * ================================================================================
5  * Copyright Copyright (c) 2019 IBM
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.dcae.analytics.web.validation;
22
23 import java.util.HashMap;
24 import java.util.HashSet;
25 import java.util.Map;
26 import java.util.Set;
27
28 import org.junit.jupiter.api.Assertions;
29 import org.junit.jupiter.api.BeforeAll;
30 import org.junit.jupiter.api.Test;
31
32 public class GenericValidationResponseTest{
33
34     public static GenericValidationResponse genericValidationResponse;
35
36     @BeforeAll
37     static void beforeAll() {
38         genericValidationResponse = new GenericValidationResponse();
39     }
40
41     @Test
42     public void testGenericValidationResponse() {
43         boolean hasError = genericValidationResponse.hasErrors();
44         Set<String> set = new HashSet<>();
45         Map<String, String> map = new HashMap<>();
46         String errorMsg = "";
47         Assertions.assertEquals(false, hasError);
48         Assertions.assertEquals(set, genericValidationResponse.getFieldNamesWithError());
49         Assertions.assertNotNull(genericValidationResponse.getErrorMessages());
50         Assertions.assertEquals(map, genericValidationResponse.getValidationResultsAsMap());
51         Assertions.assertEquals(errorMsg, genericValidationResponse.getAllErrorMessage());
52         Assertions.assertEquals(errorMsg, genericValidationResponse.getAllErrorMessage("testMsg"));
53
54     }
55 }