<commit_before>package org.apache.mesos.elasticsearch.scheduler.state;

import org.apache.mesos.Protos;
import org.apache.mesos.elasticsearch.scheduler.util.ProtoTestUtil;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;

import java.io.NotSerializableException;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;

/**
 * `Tests
 */
public class ClusterStateTest {
    private SerializableState state = mock(SerializableState.class);
    private FrameworkState frameworkState = mock(FrameworkState.class);
    private ClusterState clusterState = new ClusterState(state, frameworkState);

    @Before
    public void before() throws NotSerializableException {
        Protos.FrameworkID frameworkID = Protos.FrameworkID.newBuilder().setValue("FrameworkID").build();
        when(frameworkState.getFrameworkID()).thenReturn(frameworkID);
        when(state.get(anyString())).thenReturn(new ArrayList<Protos.TaskInfo>());
    }

    @Test
    public void shouldGetListFromZK() throws NotSerializableException {
        List<Protos.TaskInfo> taskList = clusterState.getTaskList();
        verify(state, times(1)).get(anyString());
        assertEquals(0, taskList.size());
    }

    @Test
    public void shouldHandleGetException() throws NotSerializableException {
        when(state.get(anyString())).thenThrow(NotSerializableException.class);
        List<Protos.TaskInfo> taskList = clusterState.getTaskList();
        verify(state, times(1)).get(anyString());
        assertEquals(0, taskList.size());
    }

    @Test
    public void shouldHandleGetNull() throws NotSerializableException {<commit_msg>PMD fix.<commit_after>package org.apache.mesos.elasticsearch.scheduler.state;

import org.apache.mesos.Protos;
import org.apache.mesos.elasticsearch.scheduler.util.ProtoTestUtil;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;

import java.io.NotSerializableException;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.*;
import static org.mockito.Matchers.anyString;
import static org.mockito.Mockito.*;

/**
 * `Tests
 */
@SuppressWarnings({"PMD.TooManyMethods"})
public class ClusterStateTest {
    private SerializableState state = mock(SerializableState.class);
    private FrameworkState frameworkState = mock(FrameworkState.class);
    private ClusterState clusterState = new ClusterState(state, frameworkState);

    @Before
    public void before() throws NotSerializableException {
        Protos.FrameworkID frameworkID = Protos.FrameworkID.newBuilder().setValue("FrameworkID").build();
        when(frameworkState.getFrameworkID()).thenReturn(frameworkID);
        when(state.get(anyString())).thenReturn(new ArrayList<Protos.TaskInfo>());
    }

    @Test
    public void shouldGetListFromZK() throws NotSerializableException {
        List<Protos.TaskInfo> taskList = clusterState.getTaskList();
        verify(state, times(1)).get(anyString());
        assertEquals(0, taskList.size());
    }

    @Test
    public void shouldHandleGetException() throws NotSerializableException {
        when(state.get(anyString())).thenThrow(NotSerializableException.class);
        List<Protos.TaskInfo> taskList = clusterState.getTaskList();
        verify(state, times(1)).get(anyString());
        assertEquals(0, taskList.size());
    }

    @Test
    public void shouldHandleGetNull() throws NotSerializableException {
{'fraction_non_alphanumeric': 0.11319195813825393, 'fraction_numerical': 0.002203249793445332, 'mean_word_length': 4.7017268445839875, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2148902', 'n_tokens_mistral': 1003, 'n_tokens_neox': 993, 'n_words': 186}