### Question:
CycleCheck { public <T> boolean hasCycle(Node<T> first) { boolean result = false; if (first != null) { Node<T> slow = first; Node<T> fast = first; while (!result && slow.getNext() != null && fast.getNext() != null && fast.getNext().getNext() != null) { slow = slow.getNext(); fast = fast.getNext().getNext(); if (slow.equals(fast)) { result = true; } } } return result; }  boolean hasCycle(Node<T> first);  }### Answer:
@Test public void ifListHasCycle() { first.setNext(two); two.setNext(third); third.setNext(four); four.setNext(first); assertThat(new CycleCheck().hasCycle(first), is(true)); }
@Test public void ifListHasNotCycle() { first.setNext(two); two.setNext(third); third.setNext(four); four.setNext(null); assertThat(new CycleCheck().hasCycle(first), is(false)); }
@Test public void ifListHasMediumCycle() { first.setNext(two); two.setNext(third); third.setNext(two); four.setNext(null); assertThat(new CycleCheck().hasCycle(first), is(true)); }