/** * Copyright 1999-2009 The Pegadi Team * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.pegadi.articlelist; import junit.framework.TestCase; import no.dusken.common.model.Person; import org.pegadi.model.Article; public class JournalistGrouperTest extends TestCase { JournalistGrouper grouper; Article[] articles; Person john, jane; public void setUp() { grouper = new JournalistGrouper(); john = new Person(1L, "John", "Doe", "johndoe", "john@doe.com"); jane = new Person(1L, "Jane", "Doe", "janedoe", "jane@doe.com"); articles = new Article[4]; articles[0] = new Article(); articles[0].setJournalist(john); articles[1] = new Article(); articles[1].setJournalist(john); articles[2] = new Article(); articles[2].setJournalist(jane); articles[3] = new Article(); } public void testGrouper() { GroupedArticles grouped = grouper.group(articles, new ArticleByJournalistComparator()); assertEquals(3, grouped.getNumberOfGroups()); articles[3].setJournalist(jane); grouped = grouper.group(articles, new ArticleByJournalistComparator()); assertEquals(2, grouped.getNumberOfGroups()); } public void testToString() { JournalistGrouper grouper = new JournalistGrouper(); assertEquals("Journalist", grouper.toString()); grouper = new JournalistGrouper("Journalist2"); assertEquals("Journalist2", grouper.toString()); } }