Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* 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. See accompanying
* LICENSE file.
*/
package com.gemstone.gemfire.internal.util;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.gemstone.gemfire.internal.lang.Filter;
import com.gemstone.gemfire.internal.lang.StringUtils;
import org.junit.Test;
/**
* The CollectionUtilsTest class is a test suite of test cases testing the contract and functionality of the
* CollectionUtils class.
*
* @author John Blum
* @see com.gemstone.gemfire.internal.util.CollectionUtils
* @see org.junit.Assert
* @see org.junit.Test
* @since 7.0
*/
@SuppressWarnings("null")
public class CollectionUtilsTest {
@Test
public void testAsList() {
final Integer[] numbers = { 0, 1, 2, 1, 0 };
final List numberList = CollectionUtils.asList(numbers);
assertNotNull(numberList);
assertFalse(numberList.isEmpty());
assertEquals(numbers.length, numberList.size());
assertTrue(numberList.containsAll(Arrays.asList(numbers)));
assertEquals(new Integer(0), numberList.remove(0));
assertEquals(numbers.length - 1, numberList.size());
}
@Test
public void testAsSet() {
final Integer[] numbers = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
final Set numberSet = CollectionUtils.asSet(numbers);
assertNotNull(numberSet);
assertFalse(numberSet.isEmpty());
assertEquals(numbers.length, numberSet.size());
assertTrue(numberSet.containsAll(Arrays.asList(numbers)));
assertTrue(numberSet.remove(1));
assertEquals(numbers.length - 1, numberSet.size());
}
@Test
public void testAsSetWithNonUniqueElements() {
final Integer[] numbers = { 0, 1, 2, 1, 0 };
final Set numberSet = CollectionUtils.asSet(numbers);
assertNotNull(numberSet);
assertFalse(numberSet.isEmpty());
assertEquals(3, numberSet.size());
assertTrue(numberSet.containsAll(Arrays.asList(numbers)));
}
@Test
public void testEmptyListWithNullList() {
final List