Initial search service commit
[aai/search-data-service.git] / src / test / java / org / openecomp / sa / searchdbabstraction / searchapi / SortTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * Search Data Service
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property.
6  * Copyright © 2017 Amdocs
7  * All rights reserved.
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
12  *
13  *    http://www.apache.org/licenses/LICENSE-2.0
14  *
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=========================================================
21  *
22  * ECOMP and OpenECOMP are trademarks
23  * and service marks of AT&T Intellectual Property.
24  */
25 package org.openecomp.sa.searchdbabstraction.searchapi;
26
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;
31
32 import java.io.IOException;
33
34 import static org.junit.Assert.assertTrue;
35
36 public class SortTest {
37
38   @Test
39   public void sortFieldTest() throws JsonParseException, JsonMappingException, IOException {
40
41     String field = "fieldname";
42     String order = "ascending";
43     String json = "{\"field\": \"" + field + "\", \"order\": \"" + order + "\"}";
44
45     ObjectMapper mapper = new ObjectMapper();
46     Sort sort = mapper.readValue(json, Sort.class);
47
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()));
52
53   }
54 }