@Test public void testPrepareDLConfNotAttached() { when(publicStack.getDatalakeResourceId()).thenReturn(null); when(publicStack.getEnvironmentCrn()).thenReturn(""); Workspace workspace = new Workspace(); workspace.setId(1L); when(publicStack.getWorkspace()).thenReturn(workspace); when(datalakeResourcesService.findDatalakeResourcesByWorkspaceAndEnvironment(anyLong(), anyString())) .thenReturn(Collections.emptySet()); Stack stack = underTest.prepareDatalakeConfigs(publicStack); assertNull(stack.getDatalakeResourceId()); assertEquals(publicStack.getInputs(), stack.getInputs()); verify(datalakeResourcesService, times(0)).findById(anyLong()); }
@Measure(SharedServiceConfigProvider.class) public Stack prepareDatalakeConfigs(Stack publicStack) { try { Optional<DatalakeResources> datalakeResource = Optional.empty(); Set<DatalakeResources> datalakeResources = datalakeResourcesService .findDatalakeResourcesByWorkspaceAndEnvironment(publicStack.getWorkspace().getId(), publicStack.getEnvironmentCrn()); if (publicStack.getDatalakeResourceId() != null || (!CollectionUtils.isEmpty(datalakeResources) && datalakeResources.size() == 1)) { Long datalakeResourceId = getDatalakeResourceIdFromEnvOrStack(publicStack, datalakeResources); datalakeResource = datalakeResourcesService.findById(datalakeResourceId); } else { if (publicStack.getDatalakeResourceId() == null) { LOGGER.debug("Datalake resource id was null, therefore unable to fetch resource(s)!"); } if (CollectionUtils.isEmpty(datalakeResources)) { LOGGER.debug("No datalake resource(s) has been found for environment: {}", publicStack.getEnvironmentCrn()); } } if (decorateStackWithConfigs(publicStack, datalakeResource)) { return stackService.save(publicStack); } return publicStack; } catch (IOException e) { String baseMessage = "Could not propagate cluster input parameters"; LOGGER.warn(baseMessage); throw new BadRequestException(baseMessage + ": " + e.getMessage(), e); } }
SharedServiceConfigProvider { @Measure(SharedServiceConfigProvider.class) public Stack prepareDatalakeConfigs(Stack publicStack) { try { Optional<DatalakeResources> datalakeResource = Optional.empty(); Set<DatalakeResources> datalakeResources = datalakeResourcesService .findDatalakeResourcesByWorkspaceAndEnvironment(publicStack.getWorkspace().getId(), publicStack.getEnvironmentCrn()); if (publicStack.getDatalakeResourceId() != null || (!CollectionUtils.isEmpty(datalakeResources) && datalakeResources.size() == 1)) { Long datalakeResourceId = getDatalakeResourceIdFromEnvOrStack(publicStack, datalakeResources); datalakeResource = datalakeResourcesService.findById(datalakeResourceId); } else { if (publicStack.getDatalakeResourceId() == null) { LOGGER.debug("Datalake resource id was null, therefore unable to fetch resource(s)!"); } if (CollectionUtils.isEmpty(datalakeResources)) { LOGGER.debug("No datalake resource(s) has been found for environment: {}", publicStack.getEnvironmentCrn()); } } if (decorateStackWithConfigs(publicStack, datalakeResource)) { return stackService.save(publicStack); } return publicStack; } catch (IOException e) { String baseMessage = "Could not propagate cluster input parameters"; LOGGER.warn(baseMessage); throw new BadRequestException(baseMessage + ": " + e.getMessage(), e); } } }
SharedServiceConfigProvider { @Measure(SharedServiceConfigProvider.class) public Stack prepareDatalakeConfigs(Stack publicStack) { try { Optional<DatalakeResources> datalakeResource = Optional.empty(); Set<DatalakeResources> datalakeResources = datalakeResourcesService .findDatalakeResourcesByWorkspaceAndEnvironment(publicStack.getWorkspace().getId(), publicStack.getEnvironmentCrn()); if (publicStack.getDatalakeResourceId() != null || (!CollectionUtils.isEmpty(datalakeResources) && datalakeResources.size() == 1)) { Long datalakeResourceId = getDatalakeResourceIdFromEnvOrStack(publicStack, datalakeResources); datalakeResource = datalakeResourcesService.findById(datalakeResourceId); } else { if (publicStack.getDatalakeResourceId() == null) { LOGGER.debug("Datalake resource id was null, therefore unable to fetch resource(s)!"); } if (CollectionUtils.isEmpty(datalakeResources)) { LOGGER.debug("No datalake resource(s) has been found for environment: {}", publicStack.getEnvironmentCrn()); } } if (decorateStackWithConfigs(publicStack, datalakeResource)) { return stackService.save(publicStack); } return publicStack; } catch (IOException e) { String baseMessage = "Could not propagate cluster input parameters"; LOGGER.warn(baseMessage); throw new BadRequestException(baseMessage + ": " + e.getMessage(), e); } }  }
SharedServiceConfigProvider { @Measure(SharedServiceConfigProvider.class) public Stack prepareDatalakeConfigs(Stack publicStack) { try { Optional<DatalakeResources> datalakeResource = Optional.empty(); Set<DatalakeResources> datalakeResources = datalakeResourcesService .findDatalakeResourcesByWorkspaceAndEnvironment(publicStack.getWorkspace().getId(), publicStack.getEnvironmentCrn()); if (publicStack.getDatalakeResourceId() != null || (!CollectionUtils.isEmpty(datalakeResources) && datalakeResources.size() == 1)) { Long datalakeResourceId = getDatalakeResourceIdFromEnvOrStack(publicStack, datalakeResources); datalakeResource = datalakeResourcesService.findById(datalakeResourceId); } else { if (publicStack.getDatalakeResourceId() == null) { LOGGER.debug("Datalake resource id was null, therefore unable to fetch resource(s)!"); } if (CollectionUtils.isEmpty(datalakeResources)) { LOGGER.debug("No datalake resource(s) has been found for environment: {}", publicStack.getEnvironmentCrn()); } } if (decorateStackWithConfigs(publicStack, datalakeResource)) { return stackService.save(publicStack); } return publicStack; } catch (IOException e) { String baseMessage = "Could not propagate cluster input parameters"; LOGGER.warn(baseMessage); throw new BadRequestException(baseMessage + ": " + e.getMessage(), e); } }  Cluster configureCluster(@Nonnull Cluster requestedCluster, User user, Workspace workspace); @Measure(SharedServiceConfigProvider.class) Stack prepareDatalakeConfigs(Stack publicStack); }
SharedServiceConfigProvider { @Measure(SharedServiceConfigProvider.class) public Stack prepareDatalakeConfigs(Stack publicStack) { try { Optional<DatalakeResources> datalakeResource = Optional.empty(); Set<DatalakeResources> datalakeResources = datalakeResourcesService .findDatalakeResourcesByWorkspaceAndEnvironment(publicStack.getWorkspace().getId(), publicStack.getEnvironmentCrn()); if (publicStack.getDatalakeResourceId() != null || (!CollectionUtils.isEmpty(datalakeResources) && datalakeResources.size() == 1)) { Long datalakeResourceId = getDatalakeResourceIdFromEnvOrStack(publicStack, datalakeResources); datalakeResource = datalakeResourcesService.findById(datalakeResourceId); } else { if (publicStack.getDatalakeResourceId() == null) { LOGGER.debug("Datalake resource id was null, therefore unable to fetch resource(s)!"); } if (CollectionUtils.isEmpty(datalakeResources)) { LOGGER.debug("No datalake resource(s) has been found for environment: {}", publicStack.getEnvironmentCrn()); } } if (decorateStackWithConfigs(publicStack, datalakeResource)) { return stackService.save(publicStack); } return publicStack; } catch (IOException e) { String baseMessage = "Could not propagate cluster input parameters"; LOGGER.warn(baseMessage); throw new BadRequestException(baseMessage + ": " + e.getMessage(), e); } }  Cluster configureCluster(@Nonnull Cluster requestedCluster, User user, Workspace workspace); @Measure(SharedServiceConfigProvider.class) Stack prepareDatalakeConfigs(Stack publicStack);  }