@Override
    public SuspensionReasons grantSuspensionRequest(OrchestratorContext context, ApplicationApi application)
            throws HostStateChangeDeniedException {
        var suspensionReasons = new SuspensionReasons();

        // Apply per-cluster policy
        for (ClusterApi cluster : application.getClusters()) {
            suspensionReasons.mergeWith(clusterPolicy.verifyGroupGoingDownIsFine(cluster));
        }

        // Ask Cluster Controller to set storage nodes in maintenance, unless the node is already allowed
        // to be down (or permanently down) in case they are guaranteed to be in maintenance already.
        for (StorageNode storageNode : application.getNoRemarksStorageNodesInGroupInClusterOrder()) {
            storageNode.setStorageNodeState(context, ClusterControllerNodeState.MAINTENANCE);
        }

        // Ensure all nodes in the group are marked as allowed to be down
        for (HostName hostName : application.getNodesInGroupWithStatus(HostStatus.NO_REMARKS)) {
            application.setHostState(context, hostName, HostStatus.ALLOWED_TO_BE_DOWN);
        }

        return suspensionReasons;
    }
@Test
    public void testGrantSuspension() throws HostStateChangeDeniedException {
        final HostedVespaClusterPolicy clusterPolicy = mock(HostedVespaClusterPolicy.class);
        when(clusterPolicy.verifyGroupGoingDownIsFine(any())).thenReturn(SuspensionReasons.nothingNoteworthy());
        final HostedVespaPolicy policy = new HostedVespaPolicy(clusterPolicy, clientFactory, applicationApiFactory, flagSource);
        final ApplicationApi applicationApi = mock(ApplicationApi.class);
        when(applicationApi.applicationId()).thenReturn(ApplicationId.fromSerializedForm("tenant:app:default"));

        ClusterApi clusterApi1 = mock(ClusterApi.class);
        ClusterApi clusterApi2 = mock(ClusterApi.class);
        ClusterApi clusterApi3 = mock(ClusterApi.class);
        List<ClusterApi> clusterApis = List.of(clusterApi1, clusterApi2, clusterApi3);
        when(applicationApi.getClusters()).thenReturn(clusterApis);

        StorageNode storageNode1 = mock(StorageNode.class);
        HostName hostName1 = new HostName("storage-1");
        when(storageNode1.hostName()).thenReturn(hostName1);

        HostName hostName2 = new HostName("host-2");

        StorageNode storageNode3 = mock(StorageNode.class);
        HostName hostName3 = new HostName("storage-3");
        when(storageNode1.hostName()).thenReturn(hostName3);

        List<StorageNode> upStorageNodes = List.of(storageNode1, storageNode3);
        when(applicationApi.getNoRemarksStorageNodesInGroupInClusterOrder()).thenReturn(upStorageNodes);
        // setHostState

        List<HostName> noRemarksHostNames = List.of(hostName1, hostName2, hostName3);
        when(applicationApi.getNodesInGroupWithStatus(HostStatus.NO_REMARKS)).thenReturn(noRemarksHostNames);

        InOrder order = inOrder(applicationApi, clusterPolicy, storageNode1, storageNode3);

        OrchestratorContext context = mock(OrchestratorContext.class);
        policy.grantSuspensionRequest(context, applicationApi);

        order.verify(applicationApi).getClusters();
        order.verify(clusterPolicy).verifyGroupGoingDownIsFine(clusterApi1);
        order.verify(clusterPolicy).verifyGroupGoingDownIsFine(clusterApi2);
        order.verify(clusterPolicy).verifyGroupGoingDownIsFine(clusterApi3);

        order.verify(applicationApi).getNoRemarksStorageNodesInGroupInClusterOrder();
        order.verify(storageNode1).setStorageNodeState(context, ClusterControllerNodeState.MAINTENANCE);
        order.verify(storageNode3).setStorageNodeState(context, ClusterControllerNodeState.MAINTENANCE);

        order.verify(applicationApi).getNodesInGroupWithStatus(HostStatus.NO_REMARKS);
        order.verify(applicationApi).setHostState(context, hostName1, HostStatus.ALLOWED_TO_BE_DOWN);
        order.verify(applicationApi).setHostState(context, hostName2, HostStatus.ALLOWED_TO_BE_DOWN);
        order.verify(applicationApi).setHostState(context, hostName3, HostStatus.ALLOWED_TO_BE_DOWN);

        order.verifyNoMoreInteractions();
    }