2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License ati
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
25 package org.openecomp.sa.searchdbabstraction.searchapi;
27 import com.fasterxml.jackson.core.JsonParseException;
28 import com.fasterxml.jackson.databind.JsonMappingException;
29 import com.fasterxml.jackson.databind.ObjectMapper;
30 import org.junit.Test;
32 import java.io.IOException;
34 import static org.junit.Assert.assertTrue;
36 public class SortTest {
39 public void sortFieldTest() throws JsonParseException, JsonMappingException, IOException {
41 String field = "fieldname";
42 String order = "ascending";
43 String json = "{\"field\": \"" + field + "\", \"order\": \"" + order + "\"}";
45 ObjectMapper mapper = new ObjectMapper();
46 Sort sort = mapper.readValue(json, Sort.class);
48 assertTrue("Unexpected field name in marshalled object. Expected: " + field + " Actual: " + sort.getField(),
49 field.equals(sort.getField()));
50 assertTrue("Unexpected order field in marshalled object. Expected: " + order + " Actual: " + sort.getOrder(),
51 order.equals(sort.getOrder().toString()));