/**
 * Copyright (C) 2012 Ness Computing, Inc.
 *
 * 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.
 */
/**
 * 
 */
package com.nesscomputing.service.discovery.client.internal;

import java.util.List;
import java.util.UUID;

import junit.framework.Assert;

import org.apache.commons.collections.CollectionUtils;
import org.junit.Before;
import org.junit.Test;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.nesscomputing.service.discovery.client.ServiceInformation;
import com.nesscomputing.service.discovery.client.internal.ConsistentHashRing;
import com.nesscomputing.service.discovery.client.internal.ConsistentRingGroup;

/**
 * @author christopher
 *
 */
public class TestConsistentRingGroup {
	private ConsistentRingGroup group;
	
	@Before
	public void setup() {
		List<ServiceInformation> services = Lists.newArrayList();
		services.add(new ServiceInformation("fake", "type1", UUID.randomUUID(), Maps.<String, String>newHashMap()));
		services.add(new ServiceInformation("fake", "type2", UUID.randomUUID(), Maps.<String, String>newHashMap()));
		services.add(new ServiceInformation("fake", null, UUID.randomUUID(), Maps.<String, String>newHashMap()));
		
		group = new ConsistentRingGroup(services);
	}
	
	@Test
	public void testBasic() {
		ConsistentHashRing ring = group.getRing("type1");
		Assert.assertEquals(1, ring.size());
		ServiceInformation service = (ServiceInformation) CollectionUtils.get(ring, 0);
		Assert.assertEquals("type1", service.getServiceType());
	}
	
	@Test
	public void testFallback() {
		ConsistentHashRing ring = group.getRing("type3");
		Assert.assertEquals(1, ring.size());
		ServiceInformation service = (ServiceInformation) CollectionUtils.get(ring, 0);
		Assert.assertEquals(null, service.getServiceType());
	}
}

@@ -608,10 +608,9 @@
 *%0A *
- 
 %0A
+
  */%0A
@@ -729,24 +729,18 @@
 ort 
+org.
 junit.
-framework.
 Asse
@@ -1266,18 +1266,17 @@
  group;%0A
-%09
 %0A
+
 %09@Before
@@ -1693,11 +1693,9 @@
 ));%0A
-%09%09
 %0A
+
 %09%09gr
@@ -1734,26 +1734,25 @@
 rvices);%0A%09%7D%0A
-%09
 %0A
+
 %09@Test%0A%09publ
@@ -2007,17 +2007,16 @@
 ());%0A%09%7D%0A
-%09
 %0A%09@Test%0A

Clean up warnings and whitespace errors.