Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add unit tests to satisfy coverage requirements.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos A. Munoz authored and seanf committed Jan 21, 2015
1 parent 01e5b60 commit 72fce56
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions zanata-war/src/test/java/org/zanata/ui/FilterUtilTest.java
@@ -0,0 +1,71 @@
/*
* Copyright 2015, Red Hat, Inc. and individual contributors as indicated by the
* @author tags. See the copyright.txt file in the distribution for a full
* listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this software; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
* site: http://www.fsf.org.
*/
package org.zanata.ui;

import static org.assertj.core.api.Assertions.assertThat;

import org.testng.annotations.Test;
import org.zanata.common.LocaleId;
import org.zanata.model.HLocale;
import org.zanata.model.HPerson;

import com.google.common.collect.Lists;

import java.util.List;

/**
* @author Carlos Munoz <a
* href="mailto:camunoz@redhat.com">camunoz@redhat.com</a>
*/
@Test
public class FilterUtilTest {

private static final List<HLocale> ALL_LOCALES = Lists.newArrayList(
new HLocale(
LocaleId.DE), new HLocale(LocaleId.EN), new HLocale(
LocaleId.FR));

@Test
public void filterOutEmptyPersonList() throws Exception {
assertThat(
FilterUtil.filterOutPersonList(Lists.<HPerson> newArrayList(),
Lists.<HPerson> newArrayList())).isEmpty();
}

@Test
public void filterOutSamePersonList() throws Exception {
HPerson person1 = new HPerson();
HPerson person2 = new HPerson();
HPerson person3 = new HPerson();
List<HPerson> all = Lists.newArrayList(person1, person2, person3);
List<HPerson> filter = Lists.newArrayList(person1, person2, person3);

assertThat(
FilterUtil.filterOutPersonList(all, filter)).isEmpty();
}

@Test
public void localeNotIncluded() throws Exception {
assertThat(
FilterUtil.isIncludeLocale(ALL_LOCALES,
new HLocale(LocaleId.EN), null)).isFalse();
}
}

0 comments on commit 72fce56

Please sign in to comment.