// Path: src/main/java/org/fest/util/Collections.java
// public static @NotNull <T> Collection<T> duplicatesFrom(@Nullable Collection<T> c) {
//   Set<T> duplicates = new LinkedHashSet<T>();
//   if (c == null) {
//     return duplicates;
//   }
//   Set<T> unique = newHashSet();
//   for (T e : c) {
//     if (unique.contains(e)) {
//       duplicates.add(e);
//       continue;
//     }
//     unique.add(e);
//   }
//   return duplicates;
// }


import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
import static java.util.Arrays.asList;
import static org.fest.util.Collections.duplicatesFrom;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertTrue;
/*
 * Created on Apr 29, 2007
 * 
 * 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.
 * 
 * Copyright @2007-2013 the original author or authors.
 */
package org.fest.util;




/**
 * Tests for {@link Collections#duplicatesFrom(Collection)}.
 *
 * @author Yvonne Wang
 * @author Alex Ruiz
 * @author Joel Costigliola
 */
public class Collections_duplicatesFrom_Test {
  @Test
  public void should_return_existing_duplicates() {
// Path: src/main/java/org/fest/util/Collections.java
// public static @NotNull <T> Collection<T> duplicatesFrom(@Nullable Collection<T> c) {
//   Set<T> duplicates = new LinkedHashSet<T>();
//   if (c == null) {
//     return duplicates;
//   }
//   Set<T> unique = newHashSet();
//   for (T e : c) {
//     if (unique.contains(e)) {
//       duplicates.add(e);
//       continue;
//     }
//     unique.add(e);
//   }
//   return duplicates;
// }


// Path: src/test/java/org/fest/util/Collections_duplicatesFrom_Test.java
import org.junit.Test;
import java.util.ArrayList;
import java.util.Collection;
import static java.util.Arrays.asList;
import static org.fest.util.Collections.duplicatesFrom;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertTrue;

/*
 * Created on Apr 29, 2007
 * 
 * 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.
 * 
 * Copyright @2007-2013 the original author or authors.
 */
package org.fest.util;




/**
 * Tests for {@link Collections#duplicatesFrom(Collection)}.
 *
 * @author Yvonne Wang
 * @author Alex Ruiz
 * @author Joel Costigliola
 */
public class Collections_duplicatesFrom_Test {
  @Test
  public void should_return_existing_duplicates() {
    Collection<String> duplicates = duplicatesFrom(asList("Merry", "Frodo", "Merry", "Sam", "Frodo"));