@Test public void testGetHistoryWhenNoHistory() { when(clusterService.findOneByStackCrnAndTenant(testClusterCrn, tenant)).thenReturn(Optional.of(cluster)); when(historyService.getHistory(clusterId, 10)).thenReturn(List.of()); List<AutoscaleClusterHistoryResponse> historyResponses = underTest.getHistoryByCrn(testClusterCrn, 10); assertEquals("History Response size is 0", 0, historyResponses.size()); }
@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);  }