Initial TCA commit into DCAEGEN2
[dcaegen2/analytics/tca.git] / dcae-analytics-model / src / test / java / org / openecomp / dcae / apod / analytics / model / util / json / AnalyticsModelObjectMapperSupplierTest.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T Intellectual Property. 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
21 package org.openecomp.dcae.apod.analytics.model.util.json;
22
23 import com.jayway.jsonpath.Configuration;
24 import com.jayway.jsonpath.JsonPath;
25 import com.jayway.jsonpath.Option;
26 import com.jayway.jsonpath.spi.json.JsonProvider;
27 import com.jayway.jsonpath.spi.mapper.MappingProvider;
28 import org.junit.Test;
29 import org.openecomp.dcae.apod.analytics.model.BaseAnalyticsModelUnitTest;
30
31 import java.util.Set;
32
33 import static org.hamcrest.CoreMatchers.is;
34 import static org.hamcrest.Matchers.containsInAnyOrder;
35 import static org.junit.Assert.assertThat;
36
37
38 /**
39  * @author Rajiv Singla . Creation Date: 12/16/2016.
40  */
41 public class AnalyticsModelObjectMapperSupplierTest extends BaseAnalyticsModelUnitTest {
42
43
44     @Test
45     public void testJsonPathSettings() throws Exception {
46         final Configuration configuration = JsonPath.parse("{\"test\": \"test\"}").configuration();
47
48         final JsonProvider jsonProvider = configuration.jsonProvider();
49         final String jsonProviderClassName = jsonProvider.getClass().getSimpleName();
50         assertThat("Json Provider cass name must be JacksonJsonProvider",
51                 jsonProviderClassName, is("JacksonJsonProvider"));
52
53         final MappingProvider mappingProvider = configuration.mappingProvider();
54         final String mappingProviderClassName = mappingProvider.getClass().getSimpleName();
55         assertThat("Mapping Provider cass name must be JacksonMappingProvider",
56                 mappingProviderClassName, is("JacksonMappingProvider"));
57
58         final Set<Option> configurationOptions = configuration.getOptions();
59         assertThat(configurationOptions,
60                 containsInAnyOrder(Option.DEFAULT_PATH_LEAF_TO_NULL, Option.SUPPRESS_EXCEPTIONS));
61     }
62
63 }