@Test public void testGetForInternalCrn() { when(cloudbreakUser.getUserCrn()).thenReturn("crn:altus:iam:us-west-1:altus:user:__internal__actor__"); when(stackApiViewService.retrieveStackByCrnAndType(anyString(), any(StackType.class))).thenReturn(new StackApiView()); when(converterUtil.convert(any(StackApiView.class), any())).thenReturn(new StackViewV4Response()); doNothing().when(environmentServiceDecorator).prepareEnvironment(any(StackViewV4Response.class)); StackViewV4Response response = underTest.getForInternalCrn(NameOrCrn.ofCrn("myCrn"), STACK_TYPE); assertNotNull(response); verify(stackApiViewService, times(1)).retrieveStackByCrnAndType(anyString(), any(StackType.class)); verify(converterUtil, times(1)).convert(any(StackApiView.class), any()); verify(environmentServiceDecorator, times(1)).prepareEnvironment(any(StackViewV4Response.class)); }
public StackViewV4Response getForInternalCrn(NameOrCrn nameOrCrn, StackType stackType) { LOGGER.info("Validate stack against internal user."); StackApiView stackApiView = stackApiViewService.retrieveStackByCrnAndType(nameOrCrn.getCrn(), stackType); LOGGER.info("Query Stack (view) successfully finished with crn {}", nameOrCrn.getCrn()); StackViewV4Response stackViewV4Response = converterUtil.convert(stackApiView, StackViewV4Response.class); LOGGER.info("Adding environment name to the response."); environmentServiceDecorator.prepareEnvironment(stackViewV4Response); return stackViewV4Response; }
StackOperations implements ResourceBasedCrnProvider { public StackViewV4Response getForInternalCrn(NameOrCrn nameOrCrn, StackType stackType) { LOGGER.info("Validate stack against internal user."); StackApiView stackApiView = stackApiViewService.retrieveStackByCrnAndType(nameOrCrn.getCrn(), stackType); LOGGER.info("Query Stack (view) successfully finished with crn {}", nameOrCrn.getCrn()); StackViewV4Response stackViewV4Response = converterUtil.convert(stackApiView, StackViewV4Response.class); LOGGER.info("Adding environment name to the response."); environmentServiceDecorator.prepareEnvironment(stackViewV4Response); return stackViewV4Response; } }
StackOperations implements ResourceBasedCrnProvider { public StackViewV4Response getForInternalCrn(NameOrCrn nameOrCrn, StackType stackType) { LOGGER.info("Validate stack against internal user."); StackApiView stackApiView = stackApiViewService.retrieveStackByCrnAndType(nameOrCrn.getCrn(), stackType); LOGGER.info("Query Stack (view) successfully finished with crn {}", nameOrCrn.getCrn()); StackViewV4Response stackViewV4Response = converterUtil.convert(stackApiView, StackViewV4Response.class); LOGGER.info("Adding environment name to the response."); environmentServiceDecorator.prepareEnvironment(stackViewV4Response); return stackViewV4Response; }  }
StackOperations implements ResourceBasedCrnProvider { public StackViewV4Response getForInternalCrn(NameOrCrn nameOrCrn, StackType stackType) { LOGGER.info("Validate stack against internal user."); StackApiView stackApiView = stackApiViewService.retrieveStackByCrnAndType(nameOrCrn.getCrn(), stackType); LOGGER.info("Query Stack (view) successfully finished with crn {}", nameOrCrn.getCrn()); StackViewV4Response stackViewV4Response = converterUtil.convert(stackApiView, StackViewV4Response.class); LOGGER.info("Adding environment name to the response."); environmentServiceDecorator.prepareEnvironment(stackViewV4Response); return stackViewV4Response; }  StackViewV4Responses listByEnvironmentName(Long workspaceId, String environmentName, List<StackType> stackTypes); StackViewV4Responses listByEnvironmentCrn(Long workspaceId, String environmentCrn, List<StackType> stackTypes); StackV4Response post(Long workspaceId, @Valid StackV4Request request, boolean distroxRequest); StackV4Response get(NameOrCrn nameOrCrn, Long workspaceId, Set<String> entries, StackType stackType); StackViewV4Response getForInternalCrn(NameOrCrn nameOrCrn, StackType stackType); FlowIdentifier deleteInstance(@NotNull NameOrCrn nameOrCrn, Long workspaceId, boolean forced, String instanceId); FlowIdentifier deleteInstances(NameOrCrn nameOrCrn, Long workspaceId, List<String> instanceIds, boolean forced); FlowIdentifier sync(NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier retry(NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier putStop(NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier putStart(NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier putScaling(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid StackScaleV4Request updateRequest); FlowIdentifier repairCluster(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid ClusterRepairV4Request clusterRepairRequest); FlowIdentifier upgradeOs(@NotNull NameOrCrn nameOrCrn, Long workspaceId); UpgradeOptionV4Response checkForOsUpgrade(@NotNull NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier upgradeCluster(@NotNull NameOrCrn nameOrCrn, Long workspaceId, String imageId); FlowIdentifier updateSalt(@NotNull NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier updatePillarConfiguration(@NotNull NameOrCrn nameOrCrn, Long workspaceId); UpgradeV4Response checkForClusterUpgrade(@NotNull NameOrCrn nameOrCrn, Long workspaceId, UpgradeV4Request request); GeneratedBlueprintV4Response postStackForBlueprint(@Valid StackV4Request stackRequest); FlowIdentifier changeImage(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid StackImageChangeV4Request stackImageChangeRequest); void delete(@NotNull NameOrCrn nameOrCrn, Long workspaceId, boolean forced); StackV4Request getRequest(@NotNull NameOrCrn nameOrCrn, Long workspaceId); StackStatusV4Response getStatus(@NotNull NameOrCrn nameOrCrn, Long workspaceId); StackStatusV4Response getStatusByCrn(@NotNull NameOrCrn nameOrCrn, Long workspaceId); StackStatusV4Response getStatus(@NotNull String crn); FlowIdentifier putPassword(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid UserNamePasswordV4Request userNamePasswordJson); FlowIdentifier setClusterMaintenanceMode(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @NotNull MaintenanceModeV4Request maintenanceMode); FlowIdentifier putCluster(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid UpdateClusterV4Request updateJson); String getClusterHostsInventory(Long workspaceId, String name); Stack getStackByName(String name); Stack getStackByCrn(String crn); List<RetryableFlow> getRetryableFlows(String name, Long workspaceId); FlowIdentifier backupClusterDatabase(@NotNull NameOrCrn nameOrCrn, Long workspaceId, String location, String backupId); FlowIdentifier restoreClusterDatabase(@NotNull NameOrCrn nameOrCrn, Long workspaceId, String location, String backupId); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceName); @Override List<String> getResourceCrnsInAccount(); @Override AuthorizationResourceType getResourceType(); @Override Optional<String> getEnvironmentCrnByResourceCrn(String resourceCrn); CertificatesRotationV4Response rotateClusterCertificates(@NotNull NameOrCrn nameOrCrn, Long workspaceId,
            CertificatesRotationV4Request certificatesRotationV4Request); }
StackOperations implements ResourceBasedCrnProvider { public StackViewV4Response getForInternalCrn(NameOrCrn nameOrCrn, StackType stackType) { LOGGER.info("Validate stack against internal user."); StackApiView stackApiView = stackApiViewService.retrieveStackByCrnAndType(nameOrCrn.getCrn(), stackType); LOGGER.info("Query Stack (view) successfully finished with crn {}", nameOrCrn.getCrn()); StackViewV4Response stackViewV4Response = converterUtil.convert(stackApiView, StackViewV4Response.class); LOGGER.info("Adding environment name to the response."); environmentServiceDecorator.prepareEnvironment(stackViewV4Response); return stackViewV4Response; }  StackViewV4Responses listByEnvironmentName(Long workspaceId, String environmentName, List<StackType> stackTypes); StackViewV4Responses listByEnvironmentCrn(Long workspaceId, String environmentCrn, List<StackType> stackTypes); StackV4Response post(Long workspaceId, @Valid StackV4Request request, boolean distroxRequest); StackV4Response get(NameOrCrn nameOrCrn, Long workspaceId, Set<String> entries, StackType stackType); StackViewV4Response getForInternalCrn(NameOrCrn nameOrCrn, StackType stackType); FlowIdentifier deleteInstance(@NotNull NameOrCrn nameOrCrn, Long workspaceId, boolean forced, String instanceId); FlowIdentifier deleteInstances(NameOrCrn nameOrCrn, Long workspaceId, List<String> instanceIds, boolean forced); FlowIdentifier sync(NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier retry(NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier putStop(NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier putStart(NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier putScaling(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid StackScaleV4Request updateRequest); FlowIdentifier repairCluster(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid ClusterRepairV4Request clusterRepairRequest); FlowIdentifier upgradeOs(@NotNull NameOrCrn nameOrCrn, Long workspaceId); UpgradeOptionV4Response checkForOsUpgrade(@NotNull NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier upgradeCluster(@NotNull NameOrCrn nameOrCrn, Long workspaceId, String imageId); FlowIdentifier updateSalt(@NotNull NameOrCrn nameOrCrn, Long workspaceId); FlowIdentifier updatePillarConfiguration(@NotNull NameOrCrn nameOrCrn, Long workspaceId); UpgradeV4Response checkForClusterUpgrade(@NotNull NameOrCrn nameOrCrn, Long workspaceId, UpgradeV4Request request); GeneratedBlueprintV4Response postStackForBlueprint(@Valid StackV4Request stackRequest); FlowIdentifier changeImage(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid StackImageChangeV4Request stackImageChangeRequest); void delete(@NotNull NameOrCrn nameOrCrn, Long workspaceId, boolean forced); StackV4Request getRequest(@NotNull NameOrCrn nameOrCrn, Long workspaceId); StackStatusV4Response getStatus(@NotNull NameOrCrn nameOrCrn, Long workspaceId); StackStatusV4Response getStatusByCrn(@NotNull NameOrCrn nameOrCrn, Long workspaceId); StackStatusV4Response getStatus(@NotNull String crn); FlowIdentifier putPassword(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid UserNamePasswordV4Request userNamePasswordJson); FlowIdentifier setClusterMaintenanceMode(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @NotNull MaintenanceModeV4Request maintenanceMode); FlowIdentifier putCluster(@NotNull NameOrCrn nameOrCrn, Long workspaceId, @Valid UpdateClusterV4Request updateJson); String getClusterHostsInventory(Long workspaceId, String name); Stack getStackByName(String name); Stack getStackByCrn(String crn); List<RetryableFlow> getRetryableFlows(String name, Long workspaceId); FlowIdentifier backupClusterDatabase(@NotNull NameOrCrn nameOrCrn, Long workspaceId, String location, String backupId); FlowIdentifier restoreClusterDatabase(@NotNull NameOrCrn nameOrCrn, Long workspaceId, String location, String backupId); @Override String getResourceCrnByResourceName(String resourceName); @Override List<String> getResourceCrnListByResourceNameList(List<String> resourceName); @Override List<String> getResourceCrnsInAccount(); @Override AuthorizationResourceType getResourceType(); @Override Optional<String> getEnvironmentCrnByResourceCrn(String resourceCrn); CertificatesRotationV4Response rotateClusterCertificates(@NotNull NameOrCrn nameOrCrn, Long workspaceId,
            CertificatesRotationV4Request certificatesRotationV4Request);  }