package com.hubspot.jinjava.lib.filter;

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

import java.math.BigDecimal;
import java.util.List;
import java.util.Set;

import org.junit.Before;
import org.junit.Test;

import com.google.common.collect.Lists;
import com.google.common.collect.Sets;

public class ListFilterTest {

  ListFilter filter;

  @Before
  public void setup() {
    filter = new ListFilter();
  }

  @Test
  public void itConvertsStringToListOfChars() {
    List o = (List)filter.filter("hello", null);
    assertThat(o).isEqualTo(Lists.newArrayList('h', 'e', 'l', 'l', 'o'));
  }

  @Test
  public void itConvertsSetsToLists() {
    Set<Integer> ints = Sets.newHashSet(1,2,3);
    List o = (List)filter.filter(ints, null);
    assertThat(o).isEqualTo(Lists.newArrayList(1,2,3));
  }

  @Test
  public void itWrapsNonCollectionNonStringsInLists() {
    List o = (List)filter.filter(BigDecimal.ONE, null);
    assertThat(o).isEqualTo(Lists.newArrayList(BigDecimal.ONE));
  }
}

@@ -1,8 +1,706 @@
+/**********************************************************************%0ACopyright (c) 2016 HubSpot Inc.%0A%0ALicensed under the Apache License, Version 2.0 (the %22License%22);%0Ayou may not use this file except in compliance with the License.%0AYou may obtain a copy of the License at%0A%0Ahttp://www.apache.org/licenses/LICENSE-2.0%0A%0AUnless required by applicable law or agreed to in writing, software%0Adistributed under the License is distributed on an %22AS IS%22 BASIS,%0AWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0ASee the License for the specific language governing permissions and%0Alimitations under the License.%0A **********************************************************************/%0A
 package 

add license