### Question:
ServerlessConfigurationManager { public String run(final Long configurationId, final String configName, final HttpServletRequest request) { final RunConfiguration configuration = runConfigurationManager.load(configurationId); final AbstractRunConfigurationEntry configurationEntry = configuration.getEntries().stream() .filter(config -> Objects.equals(config.getName(), configName)) .findFirst() .orElseThrow(() -> new IllegalArgumentException(String .format("Cannot find configuration with name '%s'", configName))); final PipelineRun pipelineRun = receivePipelineRun(configurationId, configuration); log.debug("Pipeline run '{}' will be used for request", pipelineRun.getId()); final StopServerlessRun stopRunInfo = getServerlessRun(pipelineRun.getId(), configurationEntry.getStopAfter()); final PipelineRun launchedRun = waitForRunInitialized(pipelineRun.getId()); final String endpointUrl = getEndpointUrl(configurationEntry, launchedRun); final String appPath = buildApplicationUrl(request, endpointUrl); log.debug("The request '{}' will be sent", appPath); final String response = sendRequest(request, appPath); stopRunInfo.setLastUpdate(LocalDateTime.now()); stopServerlessRunManager.updateServerlessRun(stopRunInfo); return response; } ServerlessConfigurationManager(final RunConfigurationManager runConfigurationManager,
                                          final ConfigurationRunner configurationRunner,
                                          final AbstractRunConfigurationMapper runConfigurationMapper,
                                          final PipelineRunManager runManager,
                                          final PreferenceManager preferenceManager,
                                          final StopServerlessRunManager stopServerlessRunManager,
                                          final ObjectMapper objectMapper,
                                          final AuthManager authManager,
                                          @Value("${edge.internal.host:}") final String edgeInternalHost,
                                          @Value("${edge.internal.port}") final Integer edgeInternalPort); String run(final Long configurationId, final String configName, final HttpServletRequest request); String generateUrl(final Long configurationId, final String config);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void shouldFailIfConfigNameNotFound() { final RunConfigurationEntry entry = runConfigurationEntry(TEST_NAME, true); final RunConfiguration configuration = runConfiguration(TEST_NAME, entry); when(runConfigurationManager.load(any())).thenReturn(configuration); serverlessConfigurationManager.run(CONFIGURATION_ID, ANOTHER_TEST_NAME, null); }
@Test(expected = IllegalArgumentException.class) public void shouldFailIfInitializationTimeExceeded() { final RunConfigurationEntry entry = runConfigurationEntry(TEST_NAME, true); final RunConfiguration configuration = runConfiguration(TEST_NAME, entry); final PipelineRun pipelineRun = pipelineRun(); final PagedResult<List<PipelineRun>> activeRuns = new PagedResult<>( Collections.singletonList(pipelineRun), 1); when(runConfigurationManager.load(any())).thenReturn(configuration); when(preferenceManager.getPreference(SystemPreferences.LAUNCH_SERVERLESS_WAIT_COUNT)).thenReturn(1); when(preferenceManager.getPreference(SystemPreferences.LAUNCH_TASK_STATUS_UPDATE_RATE)).thenReturn(1); when(runManager.loadPipelineRun(any())).thenReturn(pipelineRun); when(runManager.searchPipelineRuns(any(), anyBoolean())).thenReturn(activeRuns); when(stopServerlessRunManager.loadByRunId(any())).thenReturn(Optional.empty()); serverlessConfigurationManager.run(CONFIGURATION_ID, TEST_NAME, mockRequest()); }