@Test public void testGetHistoryWhenClusterNotFound() { when(clusterService.findOneByStackCrnAndTenant(testClusterCrn, tenant)).thenReturn(Optional.empty()); expectedException.expect(NotFoundException.class); expectedException.expectMessage("cluster 'crn:cdp:iam:us-west-1:%s:cluster:mockuser@cloudera.com' not found."); underTest.getHistoryByCrn(testClusterCrn, 10); }
@Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.SCALE_DATAHUB) public List<AutoscaleClusterHistoryResponse> getHistoryByCrn(@ResourceCrn String stackCrn, Integer historyCount) { return clusterService.findOneByStackCrnAndTenant(stackCrn, restRequestThreadLocalService.getCloudbreakTenant()) .map(cluster -> historyConverter.convertAllToJson(historyService.getHistory(cluster.getId(), historyCount))) .orElseThrow(NotFoundException.notFound("cluster", stackCrn)); }
HistoryController implements HistoryEndpoint { @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.SCALE_DATAHUB) public List<AutoscaleClusterHistoryResponse> getHistoryByCrn(@ResourceCrn String stackCrn, Integer historyCount) { return clusterService.findOneByStackCrnAndTenant(stackCrn, restRequestThreadLocalService.getCloudbreakTenant()) .map(cluster -> historyConverter.convertAllToJson(historyService.getHistory(cluster.getId(), historyCount))) .orElseThrow(NotFoundException.notFound("cluster", stackCrn)); } }
HistoryController implements HistoryEndpoint { @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.SCALE_DATAHUB) public List<AutoscaleClusterHistoryResponse> getHistoryByCrn(@ResourceCrn String stackCrn, Integer historyCount) { return clusterService.findOneByStackCrnAndTenant(stackCrn, restRequestThreadLocalService.getCloudbreakTenant()) .map(cluster -> historyConverter.convertAllToJson(historyService.getHistory(cluster.getId(), historyCount))) .orElseThrow(NotFoundException.notFound("cluster", stackCrn)); }  }
HistoryController implements HistoryEndpoint { @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.SCALE_DATAHUB) public List<AutoscaleClusterHistoryResponse> getHistoryByCrn(@ResourceCrn String stackCrn, Integer historyCount) { return clusterService.findOneByStackCrnAndTenant(stackCrn, restRequestThreadLocalService.getCloudbreakTenant()) .map(cluster -> historyConverter.convertAllToJson(historyService.getHistory(cluster.getId(), historyCount))) .orElseThrow(NotFoundException.notFound("cluster", stackCrn)); }  @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.SCALE_DATAHUB) List<AutoscaleClusterHistoryResponse> getHistoryByCrn(@ResourceCrn String stackCrn, Integer historyCount); @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.SCALE_DATAHUB) List<AutoscaleClusterHistoryResponse> getHistoryByName(@ResourceName String stackName, Integer historyCount); }
HistoryController implements HistoryEndpoint { @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.SCALE_DATAHUB) public List<AutoscaleClusterHistoryResponse> getHistoryByCrn(@ResourceCrn String stackCrn, Integer historyCount) { return clusterService.findOneByStackCrnAndTenant(stackCrn, restRequestThreadLocalService.getCloudbreakTenant()) .map(cluster -> historyConverter.convertAllToJson(historyService.getHistory(cluster.getId(), historyCount))) .orElseThrow(NotFoundException.notFound("cluster", stackCrn)); }  @Override @CheckPermissionByResourceCrn(action = AuthorizationResourceAction.SCALE_DATAHUB) List<AutoscaleClusterHistoryResponse> getHistoryByCrn(@ResourceCrn String stackCrn, Integer historyCount); @Override @CheckPermissionByResourceName(action = AuthorizationResourceAction.SCALE_DATAHUB) List<AutoscaleClusterHistoryResponse> getHistoryByName(@ResourceName String stackName, Integer historyCount);  }