@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); }
protected Comparator<Resource> getComparator() { return comparator; }
ClusterControllerImpl implements ClusterController { protected Comparator<Resource> getComparator() { return comparator; } }
ClusterControllerImpl implements ClusterController { protected Comparator<Resource> getComparator() { return comparator; } ClusterControllerImpl(ProviderModule providerModule); }
ClusterControllerImpl implements ClusterController { protected Comparator<Resource> getComparator() { return comparator; } ClusterControllerImpl(ProviderModule providerModule); @Override Predicate getAmendedPredicate(Type type, Predicate predicate); @Override QueryResponse getResources(Type type, Request request, Predicate predicate); @Override Set<Resource> populateResources(Type type,
                                         Set<Resource> resources,
                                         Request request,
                                         Predicate predicate); @Override Iterable<Resource> getIterable(Type type, QueryResponse queryResponse,
                                        Request request, Predicate predicate,
                                        PageRequest pageRequest,
                                        SortRequest sortRequest); @Override PageResponse getPage(Type type, QueryResponse queryResponse,
                              Request request, Predicate predicate,
                              PageRequest pageRequest, SortRequest sortRequest); @Override Schema getSchema(Type type); @Override RequestStatus createResources(Type type, Request request); @Override RequestStatus updateResources(Type type, Request request, Predicate predicate); @Override RequestStatus deleteResources(Type type, Request request, Predicate predicate); @Override ResourceProvider ensureResourceProvider(Type type); }
ClusterControllerImpl implements ClusterController { protected Comparator<Resource> getComparator() { return comparator; } ClusterControllerImpl(ProviderModule providerModule); @Override Predicate getAmendedPredicate(Type type, Predicate predicate); @Override QueryResponse getResources(Type type, Request request, Predicate predicate); @Override Set<Resource> populateResources(Type type,
                                         Set<Resource> resources,
                                         Request request,
                                         Predicate predicate); @Override Iterable<Resource> getIterable(Type type, QueryResponse queryResponse,
                                        Request request, Predicate predicate,
                                        PageRequest pageRequest,
                                        SortRequest sortRequest); @Override PageResponse getPage(Type type, QueryResponse queryResponse,
                              Request request, Predicate predicate,
                              PageRequest pageRequest, SortRequest sortRequest); @Override Schema getSchema(Type type); @Override RequestStatus createResources(Type type, Request request); @Override RequestStatus updateResources(Type type, Request request, Predicate predicate); @Override RequestStatus deleteResources(Type type, Request request, Predicate predicate); @Override ResourceProvider ensureResourceProvider(Type type);  }