@Test
public void testComparator() {

  TestProviderModule providerModule = new TestProviderModule();
  ClusterControllerImpl controller = new ClusterControllerImpl(providerModule);
  Comparator<Resource> comparator = controller.getComparator();
  Resource resource1 = new ResourceImpl(Resource.Type.Host);
  Resource resource2 = new ResourceImpl(Resource.Type.Host);
  Resource resource3 = new ResourceImpl(Resource.Type.Service);
  Assert.assertEquals(0, comparator.compare(resource1, resource2));
  Assert.assertEquals(0, comparator.compare(resource2, resource1));
  Assert.assertTrue(comparator.compare(resource1, resource3) < 0);
  Assert.assertTrue(comparator.compare(resource3, resource1) > 0);
  resource1.setProperty(PropertyHelper.getPropertyId("Hosts", "cluster_name"), "c1");
  resource1.setProperty(PropertyHelper.getPropertyId("Hosts", "host_name"), "h1");
  resource2.setProperty(PropertyHelper.getPropertyId("Hosts", "cluster_name"), "c1");
  resource2.setProperty(PropertyHelper.getPropertyId("Hosts", "host_name"), "h1");
  Assert.assertEquals(0, comparator.compare(resource1, resource2));
  Assert.assertEquals(0, comparator.compare(resource2, resource1));
  resource2.setProperty(PropertyHelper.getPropertyId("Hosts", "host_name"), "h2");
  Assert.assertTrue(comparator.compare(resource1, resource2) < 0);
  Assert.assertTrue(comparator.compare(resource2, resource1) > 0);
  resource2.setProperty(PropertyHelper.getPropertyId("Hosts", "host_name"), "h1");
  resource1.setProperty("p1", "foo");
  resource2.setProperty("p1", "foo");
  Assert.assertEquals(0, comparator.compare(resource1, resource2));
  Assert.assertEquals(0, comparator.compare(resource2, resource1));
  resource2.setProperty("p1", "bar");
  Assert.assertFalse(comparator.compare(resource1, resource2) == 0);
  Assert.assertFalse(comparator.compare(resource2, resource1) == 0);
}