<commit_before>package ru.matevosyan;

import org.junit.Test;
import ru.matevosyan.CycleDetection.Node;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;

/**
 * Created by Пользователь on 26.05.2017.
 */
public class CycleDetectionTest {

    @Test
    public void WhenCreateCycleListThanDetectIt() {

        CycleDetection<Integer> cycleDetection = new CycleDetection<>();

        Node<Integer> first = new Node<>(1);
        Node<Integer> two = new Node<>(2);
        Node<Integer> third = new Node<>(3);
        Node<Integer> four = new Node<>(4);

        first.next = two;
        two.next = third;
        third.next = four;
        four.next = first;

        boolean hasCycle = cycleDetection.hasCycle(first);

        assertThat(hasCycle, is(true));
    }
}<commit_msg>add a few test and javadoc<commit_after>package ru.matevosyan;

import org.junit.Test;
import ru.matevosyan.CycleDetection.Node;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;

/**
 * CycleDetectionTest class.
 * Created on 26.05.2017.
 * @author <NAME>
 * @version 1.0
 */

public class CycleDetectionTest {

    /**
     * Create WhenCreateCycleListThanDetectItAsTrue() to test cycle linked list.
     * When last element is pointer to the first, than return true.
     */

    @Test
    public void WhenCreateCycleListThanDetectItAsTrue() {

        //assign
        CycleDetection<Integer> cycleDetection = new CycleDetection<>();

        Node<Integer> first = new Node<>(1);
        Node<Integer> two = new Node<>(2);
        Node<Integer> third = new Node<>(3);
        Node<Integer> four = new Node<>(4);

        // 1 -> 2 -> 3 -> 4 -> 1
        first.next = two;
        two.next = third;
        third.next = four;
        four.next = first;

        //act
        boolean hasCycle = cycleDetection.hasCycle(first);

        //assertion
        assertThat(hasCycle, is(true));
    }

    /**
     * Create WhenCreateCycleListAndCycleItemIsNotFirstThanDetectItAsTrue() to test cycle linked list.
     * When last element is pointer to the second, than return true.
     */

    @Test
    public void WhenCreateCycleListAndCycleItemIsNotFirstThanDetectItAsTrue() {

        //assign
        CycleDetection<Integer> cycleDetection = new CycleDetection<>();

        Node<Integer> first = new Node<>(1);
        Node<Integer> two = new Node<>(2);
        Node<Integer> third = new Node<>(3);
        Node<Integer> four = new Node<>(4);

        // 1 -> 2 -> 3 -> 4 -> 2
        first.next = two;
        two.next = third;
        third.next = four;
        four.next = two;

        //act
        boolean hasCycle = cycleDetection.hasCycle(first);

        //assign
        assertThat(hasCycle, is(true));
    }

    /**
     * Create WhenCreateListWithoutCycleThanDetectItAsFalse() to test cycle linked list.
     * When last element have not next pointer, than return false.
     */

    @Test
    public void WhenCreateListWithoutCycleThanDetectItAsFalse() {

        //assign
        CycleDetection<Integer> cycleDetection = new CycleDetection<>();

        Node<Integer> first = new Node<>(1);
        Node<Integer> two = new Node<>(2);
        Node<Integer> third = new Node<>(3);
        Node<Integer> four = new Node<>(4);

        // 1 -> 2 -> 3 -> 4
        first.next = two;
        two.next = third;
        third.next = four;


        //act
        boolean hasCycle = cycleDetection.hasCycle(first);

        //assign
        assertThat(hasCycle, is(false));
    }
}
{'fraction_non_alphanumeric': 0.12105711849957375, 'fraction_numerical': 0.013640238704177323, 'mean_word_length': 2.3619866284622733, 'pattern_counts': {'":': 0, '<': 44, '<?xml version=': 0, '>': 55, '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': '1569907', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1057, 'n_words': 271}