@Test
public void testToResource() throws Exception {

  RemoteClusterResourceProvider provider = new RemoteClusterResourceProvider();
  Set<String> propertyIds = new HashSet<String>();
  propertyIds.add(RemoteClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID);
  propertyIds.add(RemoteClusterResourceProvider.CLUSTER_URL_PROPERTY_ID);
  propertyIds.add(RemoteClusterResourceProvider.USERNAME_PROPERTY_ID);
  propertyIds.add(RemoteClusterResourceProvider.PASSWORD_PROPERTY_ID);
  propertyIds.add(RemoteClusterResourceProvider.SERVICES_PROPERTY_ID);
  RemoteAmbariClusterServiceEntity service1 = createNiceMock(RemoteAmbariClusterServiceEntity.class);
  expect(service1.getServiceName()).andReturn("service1").once();
  RemoteAmbariClusterServiceEntity service2 = createNiceMock(RemoteAmbariClusterServiceEntity.class);
  expect(service2.getServiceName()).andReturn("service2").once();
  List<RemoteAmbariClusterServiceEntity> serviceList = new ArrayList<RemoteAmbariClusterServiceEntity>();
  serviceList.add(service1);
  serviceList.add(service2);
  RemoteAmbariClusterEntity entity = createNiceMock(RemoteAmbariClusterEntity.class);
  expect(entity.getName()).andReturn("test").once();
  expect(entity.getUrl()).andReturn("url").once();
  expect(entity.getUsername()).andReturn("user").once();
  expect(entity.getServices()).andReturn(serviceList).once();
  replay(service1, service2, entity);
  List<String> services = new ArrayList<String>();
  services.add("service1");
  services.add("service2");
  Resource resource = provider.toResource(propertyIds, entity);
  assertEquals(resource.getPropertyValue(RemoteClusterResourceProvider.CLUSTER_NAME_PROPERTY_ID), "test");
  assertEquals(resource.getPropertyValue(RemoteClusterResourceProvider.CLUSTER_URL_PROPERTY_ID), "url");
  assertEquals(resource.getPropertyValue(RemoteClusterResourceProvider.USERNAME_PROPERTY_ID), "user");
  assertEquals(resource.getPropertyValue(RemoteClusterResourceProvider.SERVICES_PROPERTY_ID), services);
  verify(service1, service2, entity);
}