aboutsummaryrefslogtreecommitdiffstats
path: root/compatibility-server/src/test/java/com/vaadin/data/util/ContainerOrderedWrapperTest.java
blob: c3a8b2c4f9d37f855193882217dac2c5833fc519 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.vaadin.data.util;

import java.util.Collection;

import org.junit.Test;

import com.vaadin.data.Container;
import com.vaadin.data.Item;
import com.vaadin.data.Property;

public class ContainerOrderedWrapperTest extends AbstractContainerTestBase {

    // This class is needed to get an implementation of container
    // which is not an implementation of Ordered interface.
    private class NotOrderedContainer implements Container {

        private IndexedContainer container;

        public NotOrderedContainer() {
            container = new IndexedContainer();
        }

        @Override
        public Item getItem(Object itemId) {
            return container.getItem(itemId);
        }

        @Override
        public Collection<?> getContainerPropertyIds() {
            return container.getContainerPropertyIds();
        }

        @Override
        public Collection<?> getItemIds() {
            return container.getItemIds();
        }

        @Override
        public Property getContainerProperty(Object itemId, Object propertyId) {
            return container.getContainerProperty(itemId, propertyId);
        }

        @Override
        public Class<?> getType(Object propertyId) {
            return container.getType(propertyId);
        }

        @Override
        public int size() {
            return container.size();
        }

        @Override
        public boolean containsId(Object itemId) {
            return container.containsId(itemId);
        }

        @Override
        public Item addItem(Object itemId)
                throws UnsupportedOperationException {
            return container.addItem(itemId);
        }

        @Override
        public Object addItem() throws UnsupportedOperationException {
            return container.addItem();
        }

        @Override
        public boolean removeItem(Object itemId)
                throws UnsupportedOperationException {
            return container.removeItem(itemId);
        }

        @Override
        public boolean addContainerProperty(Object propertyId, Class<?> type,
                Object defaultValue) throws UnsupportedOperationException {
            return container.addContainerProperty(propertyId, type,
                    defaultValue);
        }

        @Override
        public boolean removeContainerProperty(Object propertyId)
                throws UnsupportedOperationException {
            return container.removeContainerProperty(propertyId);
        }

        @Override
        public boolean removeAllItems() throws UnsupportedOperationException {
            return container.removeAllItems();
        }

    }

    @Test
    public void testBasicOperations() {
        testBasicContainerOperations(
                new ContainerOrderedWrapper(new NotOrderedContainer()));
    }

    @Test
    public void testOrdered() {
        testContainerOrdered(
                new ContainerOrderedWrapper(new NotOrderedContainer()));
    }

}