2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.sdc.workflow.api.types;
19 import static org.junit.Assert.assertEquals;
21 import java.util.Arrays;
22 import java.util.Collections;
23 import org.junit.Test;
24 import org.junit.runner.RunWith;
25 import org.mockito.InjectMocks;
26 import org.onap.sdc.workflow.services.types.Sort;
27 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
29 @RunWith(SpringJUnit4ClassRunner.class)
30 public class SortingTest {
33 private Sorting sorting;
36 public void setSortInvalid() {
37 sorting.setSort("name:asc:a,:,");
38 assertEquals(Collections.emptyList(), sorting.getSorts());
42 public void setSortAscByDefault() {
43 sorting.setSort("name");
44 assertEquals(Collections.singletonList(new Sort("name", true)), sorting.getSorts());
48 public void setSortAsc() {
49 sorting.setSort("name:asc");
50 assertEquals(Collections.singletonList(new Sort("name", true)), sorting.getSorts());
54 public void setSortDesc() {
55 sorting.setSort("name:desc");
56 assertEquals(Collections.singletonList(new Sort("name", false)), sorting.getSorts());
60 public void setSortMoreThanOne() {
61 sorting.setSort("name:asc,type,date:desc");
62 assertEquals(Arrays.asList(
63 new Sort("name", true),
64 new Sort("type", true),
65 new Sort("date", false)), sorting.getSorts());