Package org.rssowl.ui.internal.editors.feed

Examples of org.rssowl.ui.internal.editors.feed.NewsComparator


    INews news3 = Owl.getModelFactory().createNews(null, feed, new Date());
    news3.setTitle("C News");
    DynamicDAO.save(feed);

    NewsComparator comp = new NewsComparator();

    /* By Title */
    comp.setSortBy(NewsColumn.TITLE);
    comp.setAscending(true);
    Object[] elements = new Object[] { news1, news2, news3 };
    comp.sort(null, elements);

    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("C News", ((INews) elements[2]).getTitle());

    /* By Date */
    comp.setSortBy(NewsColumn.DATE);
    comp.setAscending(false);

    comp.sort(null, elements);

    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("A News", ((INews) elements[2]).getTitle());

    /* By Label */
    comp.setSortBy(NewsColumn.LABELS);

    comp.sort(null, elements);

    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("A News", ((INews) elements[2]).getTitle());

    ILabel label1 = Owl.getModelFactory().createLabel(null, "Label 1");
    label1.setOrder(0);

    ILabel label2 = Owl.getModelFactory().createLabel(null, "Label 2");
    label2.setOrder(1);

    ILabel label3 = Owl.getModelFactory().createLabel(null, "Label 3");
    label3.setOrder(2);

    news1.addLabel(label1);
    comp.setAscending(true);

    comp.sort(null, elements);

    /*
     * News 1: Label_1
     * News 3: -
     * News 2: -
     */
    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("C News", ((INews) elements[1]).getTitle());
    assertEquals("B News", ((INews) elements[2]).getTitle());

    news1.addLabel(label2);

    comp.sort(null, elements);

    /*
     * News 1: Label_1, Label_2
     * News 3: -
     * News 2: -
     */
    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("C News", ((INews) elements[1]).getTitle());
    assertEquals("B News", ((INews) elements[2]).getTitle());

    news2.addLabel(label1);

    comp.sort(null, elements);

    /*
     * News 1: Label_1, Label_2
     * News 2: Label_1
     * News 3: -
     */
    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("C News", ((INews) elements[2]).getTitle());

    comp.setAscending(false);
    comp.sort(null, elements);

    /*
     * News 3: -
     * News 2: Label_1
     * News 1: Label_1, Label_2
     */
    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("A News", ((INews) elements[2]).getTitle());

    news3.addLabel(label2);

    comp.setAscending(true);
    comp.sort(null, elements);

    /*
     * News 1: Label_1, Label_2
     * News 2: Label_1
     * News 3: Label_2
     */
    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("C News", ((INews) elements[2]).getTitle());

    news3.addLabel(label1);

    comp.sort(null, elements);

    /*
     * News 3: Label_1, Label_2
     * News 1: Label_1, Label_2
     * News 2: Label_1
     */
    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("A News", ((INews) elements[1]).getTitle());
    assertEquals("B News", ((INews) elements[2]).getTitle());

    news3.addLabel(label3);

    comp.sort(null, elements);

    /*
     * News 3: Label_1, Label_2, Label_3
     * News 1: Label_1, Label_2
     * News 2: Label_1
     */
    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("A News", ((INews) elements[1]).getTitle());
    assertEquals("B News", ((INews) elements[2]).getTitle());

    news2.addLabel(label3);

    comp.sort(null, elements);

    /*
     * News 3: Label_1, Label_2, Label_3
     * News 1: Label_1, Label_2
     * News 2: Label_1, Label_3
View Full Code Here


    INews news3 = Owl.getModelFactory().createNews(null, feed, new Date());
    news3.setTitle("C News");
    DynamicDAO.save(feed);

    NewsComparator comp = new NewsComparator();

    /* By Title */
    comp.setSortBy(NewsColumn.TITLE);
    comp.setAscending(true);
    Object[] elements = new Object[] { news1, news2, news3 };
    comp.sort(null, elements);

    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("C News", ((INews) elements[2]).getTitle());

    /* By Date */
    comp.setSortBy(NewsColumn.DATE);
    comp.setAscending(false);

    comp.sort(null, elements);

    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("A News", ((INews) elements[2]).getTitle());

    /* By Label */
    comp.setSortBy(NewsColumn.LABELS);

    comp.sort(null, elements);

    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("A News", ((INews) elements[2]).getTitle());

    ILabel label1 = Owl.getModelFactory().createLabel(null, "Label 1");
    label1.setOrder(0);

    ILabel label2 = Owl.getModelFactory().createLabel(null, "Label 2");
    label2.setOrder(1);

    ILabel label3 = Owl.getModelFactory().createLabel(null, "Label 3");
    label3.setOrder(2);

    news1.addLabel(label1);
    comp.setAscending(true);

    comp.sort(null, elements);

    /*
     * News 1: Label_1 News 3: - News 2: -
     */
    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("C News", ((INews) elements[1]).getTitle());
    assertEquals("B News", ((INews) elements[2]).getTitle());

    news1.addLabel(label2);

    comp.sort(null, elements);

    /*
     * News 1: Label_1, Label_2 News 3: - News 2: -
     */
    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("C News", ((INews) elements[1]).getTitle());
    assertEquals("B News", ((INews) elements[2]).getTitle());

    news2.addLabel(label1);

    comp.sort(null, elements);

    /*
     * News 1: Label_1, Label_2 News 2: Label_1 News 3: -
     */
    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("C News", ((INews) elements[2]).getTitle());

    comp.setAscending(false);
    comp.sort(null, elements);

    /*
     * News 3: - News 2: Label_1 News 1: Label_1, Label_2
     */
    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("A News", ((INews) elements[2]).getTitle());

    news3.addLabel(label2);

    comp.setAscending(true);
    comp.sort(null, elements);

    /*
     * News 1: Label_1, Label_2 News 2: Label_1 News 3: Label_2
     */
    assertEquals("A News", ((INews) elements[0]).getTitle());
    assertEquals("B News", ((INews) elements[1]).getTitle());
    assertEquals("C News", ((INews) elements[2]).getTitle());

    news3.addLabel(label1);

    comp.sort(null, elements);

    /*
     * News 3: Label_1, Label_2 News 1: Label_1, Label_2 News 2: Label_1
     */
    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("A News", ((INews) elements[1]).getTitle());
    assertEquals("B News", ((INews) elements[2]).getTitle());

    news3.addLabel(label3);

    comp.sort(null, elements);

    /*
     * News 3: Label_1, Label_2, Label_3 News 1: Label_1, Label_2 News 2:
     * Label_1
     */
    assertEquals("C News", ((INews) elements[0]).getTitle());
    assertEquals("A News", ((INews) elements[1]).getTitle());
    assertEquals("B News", ((INews) elements[2]).getTitle());

    news2.addLabel(label3);

    comp.sort(null, elements);

    /*
     * News 3: Label_1, Label_2, Label_3 News 1: Label_1, Label_2 News 2:
     * Label_1, Label_3
     */
 
View Full Code Here

TOP

Related Classes of org.rssowl.ui.internal.editors.feed.NewsComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.