Remove superflous surrounding quotes
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / externalupload / utils / ServiceUtilsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 Nokia. All rights reserved.
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 package org.openecomp.sdc.externalupload.utils;
21
22 import org.junit.Test;
23
24 import java.util.Map;
25 import java.util.Optional;
26 import java.util.Set;
27
28 import static org.junit.Assert.assertEquals;
29 import static org.junit.Assert.assertNotEquals;
30 import static org.junit.Assert.assertTrue;
31
32 public class ServiceUtilsTest {
33
34     private static final String INVALID_MODEL = "Invalid model";
35     private static final String OBJ_1 = "obj1";
36     private static final String PROP = "prop";
37
38     @Test
39     public void shouldCreateObjectUsingSetters() throws Exception {
40         TestModel testModel = getTestModel();
41         Optional<TestModel> objectUsingSetters = ServiceUtils.createObjectUsingSetters(testModel, TestModel.class);
42         assertNotEquals(objectUsingSetters.orElseThrow(() -> new Exception(INVALID_MODEL)), testModel);
43         assertEquals(objectUsingSetters.orElseThrow(() -> new Exception(INVALID_MODEL)).getProp(), testModel.getProp());
44     }
45
46     @Test
47     public void shouldGetObjectAsMap() {
48         TestModel testModel = getTestModel();
49         Map<String, Object> objectAsMap = ServiceUtils.getObjectAsMap(testModel);
50         assertEquals(objectAsMap.size(), 1);
51         assertEquals(objectAsMap.get(PROP), OBJ_1);
52     }
53
54     @Test
55     public void shouldGetClassFieldNames() {
56         Set<String> classFieldNames = ServiceUtils.getClassFieldNames(TestModel.class);
57         assertTrue(classFieldNames.contains(PROP));
58     }
59
60     private TestModel getTestModel() {
61         TestModel testModel = new TestModel();
62         testModel.setProp(OBJ_1);
63         return testModel;
64     }
65
66 }