<commit_before>package seedu.task.model;

import static org.junit.Assert.assertSame;
import static seedu.task.testutil.TestUtil.assertThrows;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import javafx.collections.FXCollections;
import seedu.task.commons.core.UnmodifiableObservableList;

public class UnmodifiableObservableListTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    private List<Integer> backing;
    private UnmodifiableObservableList<Integer> list;

    @Before
    public void setUp() {
        backing = new ArrayList<>();
        backing.add(10);
        list = new UnmodifiableObservableList<>(FXCollections.observableList(backing));
    }

    @Test
    public void transformationListGenerators_correctBackingList() {
        assertSame(list.sorted().getSource(), list);
        assertSame(list.filtered(i -> true).getSource(), list);<commit_msg>Added more testcases.<commit_after>package seedu.task.model;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static seedu.task.testutil.TestUtil.assertThrows;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;

import javafx.collections.FXCollections;
import seedu.task.commons.core.UnmodifiableObservableList;

public class UnmodifiableObservableListTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();

    private List<Integer> backing;
    private UnmodifiableObservableList<Integer> list;
    private UnmodifiableObservableList<Integer> listCopy;
    private UnmodifiableObservableList<Integer> listMoreElements;

    @Before
    public void setUp() {
        backing = new ArrayList<>();
        backing.add(10);
        list = new UnmodifiableObservableList<>(FXCollections.observableList(backing));
        listCopy = new UnmodifiableObservableList<>(FXCollections.observableList(backing));
        backing.add(1);
        backing.add(4);
        backing.add(3);
        backing.add(4);
        listMoreElements = new UnmodifiableObservableList<>(FXCollections.observableList(backing));
    }

    @Test
    public void equal_symmentric() {
        assertTrue(list.equals(listCopy));
        assertTrue(list.hashCode() == listCopy.hashCode());
    }

    @Test
    public void indexOf_success() {
        assertTrue(list.indexOf(10) == 0);
        assertTrue(listMoreElements.indexOf(4) == 2);
    }

    @Test
    public void lastIndexOf_success() {
        assertTrue(list.lastIndexOf(10) == 0);
        assertTrue(listMoreElements.lastIndexOf(4) == 4);
    }

    @Test
    public void sublist_success() {
        UnmodifiableObservableList<Integer> expectedList = new UnmodifiableObservableList<>(
                FXCollections.observableList(backing.subList(1, 3)));
        assertTrue(listMoreElements.subList(1, 3).equals(expectedList));
    }

    @Test
    public void toArray_success() {
        Object[] array = list.toArray();
        for (Object o : array) {
            assertTrue(list.contains((Integer) o));
        }
    }

    @Test
    public void setAll_fail() {
        thrown.expect(UnsupportedOperationException.class);
        ArrayList<Integer> al = new ArrayList<>();
        al.add(10);
        al.add(11);
        list.setAll(al);
    }

    @Test
    public void contains_success() {
        assertTrue(list.contains(10));
    }

    @Test
    public void contains_fail() {
        assertFalse(list.contains(11));
    }

    @Test
    public void containsAll_success() {
        ArrayList<Integer> al = new ArrayList<>();
        al.add(10);
        assertTrue(list.containsAll(al));
    }

    @Test
    public void containsAll_fail() {
        ArrayList<Integer> al = new ArrayList<>();
        al.add(10);
        al.add(11);
        assertFalse(list.containsAll(al));

    }

    @Test
    public void listIterator_previous_and_next_success() {
        ListIterator<Integer> iterator = listMoreElements.listIterator(1);
        assertTrue(iterator.hasNext());
        assertTrue(iterator.hasPrevious());
    }

    @Test
    public void transformationListGenerators_correctBackingList() {
        assertSame(list.sorted().getSource(), list);
        assertSame(list.filtered(i -> true).getSource(), list);
{'fraction_non_alphanumeric': 0.11161000641436819, 'fraction_numerical': 0.007911054094505024, 'mean_word_length': 3.446768060836502, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5563692', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1342, 'n_words': 251}