@Test
    public void testIsQuiescent() {
        StatusService statusService = new ZkStatusService(new MockCurator(),
                                                          mock(Metric.class),
                                                          new TestTimer(),
                                                          new DummyAntiServiceMonitor());

        HostName hostName = new HostName("my.host");
        HostName ccHost = new HostName("cc.host");
        TenantId tenantId = new TenantId("tenant");
        ApplicationInstanceId applicationInstanceId = new ApplicationInstanceId("app:env:region:instance");
        ApplicationInstanceReference reference = new ApplicationInstanceReference(tenantId, applicationInstanceId);
        ApplicationId id = ApplicationId.from("tenant", "app", "instance");

        ApplicationInstance applicationInstance =
                new ApplicationInstance(tenantId,
                                        applicationInstanceId,
                                        Set.of(new ServiceCluster(new ClusterId("foo"),
                                                                  ServiceType.STORAGE,
                                                                  Set.of(new ServiceInstance(new ConfigId("foo/storage/1"),
                                                                                             hostName,
                                                                                             ServiceStatus.UP),
                                                                         new ServiceInstance(new ConfigId("foo/storage/2"),
                                                                                             hostName,
                                                                                             ServiceStatus.UP))),
                                               new ServiceCluster(new ClusterId("bar"),
                                                                  ServiceType.SEARCH,
                                                                  Set.of(new ServiceInstance(new ConfigId("bar/storage/0"),
                                                                                             hostName,
                                                                                             ServiceStatus.UP),
                                                                         new ServiceInstance(new ConfigId("bar/storage/3"),
                                                                                             hostName,
                                                                                             ServiceStatus.UP))),
                                               new ServiceCluster(new ClusterId("cluster-controllers"),
                                                                  ServiceType.CLUSTER_CONTROLLER,
                                                                  Set.of(new ServiceInstance(new ConfigId("what/standalone/cluster-controllers/0"),
                                                                                             ccHost,
                                                                                             ServiceStatus.UP)))));

        ServiceMonitor serviceMonitor = () -> new ServiceModel(Map.of(reference, applicationInstance));

        ClusterControllerClientFactory clusterControllerClientFactory = mock(ClusterControllerClientFactory.class);
        ClusterControllerClient fooClient = mock(ClusterControllerClient.class);
        ClusterControllerClient barClient = mock(ClusterControllerClient.class);
        when(clusterControllerClientFactory.createClient(List.of(ccHost), "foo")).thenReturn(fooClient);
        when(clusterControllerClientFactory.createClient(List.of(ccHost), "bar")).thenReturn(barClient);

        orchestrator = new OrchestratorImpl(new HostedVespaPolicy(new HostedVespaClusterPolicy(flagSource, zone),
                                                                  clusterControllerClientFactory,
                                                                  applicationApiFactory,
                                                                  flagSource),
                                            clusterControllerClientFactory,
                                            statusService,
                                            serviceMonitor,
                                            0,
                                            new ManualClock(),
                                            applicationApiFactory,
                                            flagSource);

        when(fooClient.trySetNodeState(any(), any(), eq(1), eq(ClusterControllerNodeState.MAINTENANCE), eq(ContentService.STORAGE_NODE), eq(false))).thenReturn(true);
        when(fooClient.trySetNodeState(any(), any(), eq(2), eq(ClusterControllerNodeState.MAINTENANCE), eq(ContentService.STORAGE_NODE), eq(false))).thenReturn(true);
        when(barClient.trySetNodeState(any(), any(), eq(0), eq(ClusterControllerNodeState.MAINTENANCE), eq(ContentService.STORAGE_NODE), eq(false))).thenReturn(true);
        when(barClient.trySetNodeState(any(), any(), eq(3), eq(ClusterControllerNodeState.MAINTENANCE), eq(ContentService.STORAGE_NODE), eq(false))).thenReturn(true);
        assertTrue(orchestrator.isQuiescent(id));

        when(fooClient.trySetNodeState(any(), any(), eq(2), eq(ClusterControllerNodeState.MAINTENANCE), eq(ContentService.STORAGE_NODE), eq(false))).thenReturn(false);
        assertFalse(orchestrator.isQuiescent(id));

        when(fooClient.trySetNodeState(any(), any(), eq(2), eq(ClusterControllerNodeState.MAINTENANCE), eq(ContentService.STORAGE_NODE), eq(false))).thenThrow(new RuntimeException());
        assertFalse(orchestrator.isQuiescent(id));
    }
Test Orchestrator with a mock backend (the MockCurator)

@author smorgrav
orchestrator/src/test/java/com/yahoo/vespa/orchestrator/OrchestratorImplTest.java