<commit_before>/**
 * Copyright 2010 CosmoCode GmbH
 *
 * 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 de.cosmocode.rendering;

import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.RandomAccess;

import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.cosmocode.commons.reflect.Reflection;
import de.cosmocode.junit.UnitProvider;

/**
 * Tests {@link Mappings#defaultMapping()}.
 *
 * @since 1.2
 * @author <NAME>
 */
public final class DefaultMappingTest implements UnitProvider<Mapping> {

    private static final Logger LOG = LoggerFactory.getLogger(DefaultMappingTest.class);
    
    @Override
    public Mapping unit() {
        return Mappings.defaultMapping();
    }
    
    /**
     * Tests all steps for {@link ArrayList}.
     */
    @Test
    public void arraylist() {
        final Iterable<Class<?>> all = Reflection.getAllSuperTypes(ArrayList.class);
        final Iterator<Class<?>> iterator = all.iterator();
        
        LOG.debug("{}", all);
        
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(ArrayList.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(AbstractList.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(List.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(RandomAccess.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Cloneable.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Serializable.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(AbstractCollection.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(List.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Collection.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Object.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Collection.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Collection.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Iterable.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Iterable.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Iterable.class, iterator.next());
        Assert.assertFalse(iterator.hasNext());
    }

}<commit_msg>added 2 more tests<commit_after>/**
 * Copyright 2010 CosmoCode GmbH
 *
 * 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 de.cosmocode.rendering;

import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import java.util.RandomAccess;

import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.cosmocode.commons.reflect.Reflection;
import de.cosmocode.junit.UnitProvider;

/**
 * Tests {@link Mappings#defaultMapping()}.
 *
 * @since 1.2
 * @author <NAME>
 */
public final class DefaultMappingTest implements UnitProvider<Mapping> {

    private static final Logger LOG = LoggerFactory.getLogger(DefaultMappingTest.class);
    
    @Override
    public Mapping unit() {
        return Mappings.defaultMapping();
    }
    
    /**
     * Tests all steps for {@link ArrayList}.
     */
    @Test
    public void arraylist() {
        final Iterable<Class<?>> all = Reflection.getAllSuperTypes(ArrayList.class);
        final Iterator<Class<?>> iterator = all.iterator();
        
        LOG.debug("{}", all);
        
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(ArrayList.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(AbstractList.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(List.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(RandomAccess.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Cloneable.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Serializable.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(AbstractCollection.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(List.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Collection.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Object.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Collection.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Collection.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Iterable.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Iterable.class, iterator.next());
        Assert.assertTrue(iterator.hasNext());
        Assert.assertSame(Iterable.class, iterator.next());
        Assert.assertFalse(iterator.hasNext());
    }
    
    /**
     * Tests with a list class.
     * 
     * @since
     */
    @Test
    public void list() {
        Assert.assertSame(IterableValueRenderer.INSTANCE, unit().find(Arrays.asList().getClass()));
    }
    
    /**
     * Tests with a set class.
     * 
     * @since
     */
    @Test
    public void set() {
        Assert.assertSame(IterableValueRenderer.INSTANCE, unit().find(EnumSet.class));
    }

}
{'fraction_non_alphanumeric': 0.1252223894895306, 'fraction_numerical': 0.0034213767620090325, 'mean_word_length': 3.3734290843806103, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '676415', 'n_tokens_mistral': 1956, 'n_tokens_neox': 1970, 'n_words': 439}