From 72fce56b7041e8cec9aa61d1633950b020d1328b Mon Sep 17 00:00:00 2001 From: "Carlos A. Munoz" Date: Mon, 5 Jan 2015 16:00:49 +1000 Subject: [PATCH] Add unit tests to satisfy coverage requirements. --- .../java/org/zanata/ui/FilterUtilTest.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 zanata-war/src/test/java/org/zanata/ui/FilterUtilTest.java diff --git a/zanata-war/src/test/java/org/zanata/ui/FilterUtilTest.java b/zanata-war/src/test/java/org/zanata/ui/FilterUtilTest.java new file mode 100644 index 0000000000..efda7eb868 --- /dev/null +++ b/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 camunoz@redhat.com + */ +@Test +public class FilterUtilTest { + + private static final List 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. newArrayList(), + Lists. newArrayList())).isEmpty(); + } + + @Test + public void filterOutSamePersonList() throws Exception { + HPerson person1 = new HPerson(); + HPerson person2 = new HPerson(); + HPerson person3 = new HPerson(); + List all = Lists.newArrayList(person1, person2, person3); + List 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(); + } +}