2 * ===============================LICENSE_START======================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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===========================================
21 package org.onap.dcae.apod.analytics.model.util.json;
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.onap.dcae.apod.analytics.model.BaseAnalyticsModelUnitTest;
33 import static org.hamcrest.CoreMatchers.is;
34 import static org.hamcrest.Matchers.containsInAnyOrder;
35 import static org.junit.Assert.assertThat;
39 * @author Rajiv Singla . Creation Date: 12/16/2016.
41 public class AnalyticsModelObjectMapperSupplierTest extends BaseAnalyticsModelUnitTest {
45 public void testJsonPathSettings() throws Exception {
46 final Configuration configuration = JsonPath.parse("{\"test\": \"test\"}").configuration();
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"));
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"));
58 final Set<Option> configurationOptions = configuration.getOptions();
59 assertThat(configurationOptions,
60 containsInAnyOrder(Option.DEFAULT_PATH_LEAF_TO_NULL, Option.SUPPRESS_EXCEPTIONS,
61 Option.ALWAYS_RETURN_LIST));