Quantcast

[JIRA] (GLAZEDLISTS-599) GroupingList produces invalid ListChanges

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[JIRA] (GLAZEDLISTS-599) GroupingList produces invalid ListChanges

JIRA jira-no-reply@java.net

    [ https://java.net/jira/browse/GLAZEDLISTS-599?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=394152#comment-394152 ]

brands commented on GLAZEDLISTS-599:
------------------------------------

A more verbose "practical" example is this:
{code}
    @Test
    public void testGroupingBug() {
        BasicEventList<Element> base = new BasicEventList<Element>();
        base.add(new Element(State.OFF, 70012));
        base.add(new Element(State.OFF, 70027));

        TransactionList<Element> trigger = new TransactionList<Element>(base);
        GroupingList<Element> groupingList = new GroupingList<Element>(trigger, new Comparator<Element>() {
            @Override
            public int compare(Element o1, Element o2) {
                return o1.getState().compareTo(o2.getState());
            }
        });
//        ListConsistencyListener<List<Element>> listener = ListConsistencyListener.<List<Element>>install(groupingList, "GROUPED:", true);
//        listener.setPreviousElementTracked(false);

        FunctionList<List<Element>, State> functionList = new FunctionList<List<Element>, State>(groupingList,
                new Function<List<Element>, State>() {
                    @Override
                    public State evaluate(List<Element> sourceValues) {
                        return sourceValues.get(0).getState();
                    }
                });

        trigger.beginEvent(true);
        trigger.add(0, new Element(State.OFF, 70001));
        trigger.set(1, new Element(State.OFF, 70012));
        trigger.add(3, new Element(State.OFF, 70056));

        trigger.commitEvent();
        System.out.println(groupingList);
        System.out.println(functionList);
    }
    // trigger.add(0, new Element(Personengruppe.KREDITOREN, Kontonummer.valueOf(70001)));
    // trigger.set(1, new Element(Personengruppe.KREDITOREN, Kontonummer.valueOf(70012)));
    // trigger.add(3, new Element(Personengruppe.KREDITOREN, Kontonummer.valueOf(70056)));

    public class Element {
        private final State state;

        private final int nummer;

        public State getState() {
            return state;
        }

        public int getNummer() {
            return nummer;
        }

        public Element(State state, int nummer) {
            this.state = state;
            this.nummer = nummer;
        }

        @Override
        public String toString() {
            return state + "-" + nummer;
        }
    }

    public enum State {
        ON, OFF;
    }
{code}

> GroupingList produces invalid ListChanges
> -----------------------------------------
>
>                 Key: GLAZEDLISTS-599
>                 URL: https://java.net/jira/browse/GLAZEDLISTS-599
>             Project: glazedlists
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.10.0, 1.9.1
>            Reporter: brands
>            Assignee: jessewilson
>             Fix For: 1.10.0
>
>
> Another test for GroupingList that still fails:
> {code}
>     @Test
>     public void testIssue599() {
>         BasicEventList<String> base = new BasicEventList<String>();
>         base.add("A");
>         base.add("A");
>         TransactionList<String> source = new TransactionList<String>(base);
>         GroupingList<String> grouped = new GroupingList<String>(source, String.CASE_INSENSITIVE_ORDER);
>         ListConsistencyListener<List<String>> listener = ListConsistencyListener.<List<String>>install(grouped, "GROUPED:", true);
>         listener.setPreviousElementTracked(false);
>         source.beginEvent(true);
>         source.add(0, "A");
>         source.set(1, "A");
>         source.add(3, "A");
>         source.commitEvent();
>         assertEquals("[[A, A, A, A]]", grouped.toString());
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2.3#6260)
Loading...