### Question:
ComputationalServiceImpl implements ComputationalService { @Override public Optional<UserComputationalResource> getComputationalResource(String user, String project, String exploratoryName, String computationalName) { try { return Optional.of(computationalDAO.fetchComputationalFields(user, project, exploratoryName, computationalName)); } catch (DlabException e) { log.warn("Computational resource {} affiliated with exploratory {} for user {} not found.", computationalName, exploratoryName, user); } return Optional.empty(); } @Inject  ComputationalServiceImpl(ProjectService projectService, ExploratoryDAO exploratoryDAO, ComputationalDAO computationalDAO,
									@Named(ServiceConsts.PROVISIONING_SERVICE_NAME) RESTService provisioningService,
									RequestBuilder requestBuilder, RequestId requestId, TagService tagService,
									EndpointService endpointService, InfrastructureTemplateService templateService); @Override ComputationalTemplatesDTO getComputationalNamesAndTemplates(UserInfo user, String project, String endpoint); @BudgetLimited @Override boolean createSparkCluster(UserInfo userInfo, SparkStandaloneClusterCreateForm form, @Project String project); @Override void terminateComputational(UserInfo userInfo, String project, String exploratoryName, String computationalName); @BudgetLimited @Override boolean createDataEngineService(UserInfo userInfo, ComputationalCreateFormDTO formDTO,
										   UserComputationalResource computationalResource, @Project String project); @Override void stopSparkCluster(UserInfo userInfo, String project, String expName, String compName); @BudgetLimited @Override void startSparkCluster(UserInfo userInfo, String expName, String compName, @Project String project); @Override void updateSparkClusterConfig(UserInfo userInfo, String project, String exploratoryName, String computationalName,
										 List<ClusterConfig> config); @Override Optional<UserComputationalResource> getComputationalResource(String user, String project, String exploratoryName,
																		String computationalName); @Override List<ClusterConfig> getClusterConfig(UserInfo userInfo, String project, String exploratoryName, String computationalName);  }### Answer:
@Test public void getComputationalResource() { when(computationalDAO.fetchComputationalFields(anyString(), anyString(), anyString(), anyString())).thenReturn(ucResource); Optional<UserComputationalResource> expectedResource = Optional.of(ucResource); Optional<UserComputationalResource> actualResource = computationalService.getComputationalResource(USER, PROJECT, EXPLORATORY_NAME, COMP_NAME); assertEquals(expectedResource, actualResource); verify(computationalDAO).fetchComputationalFields(USER, PROJECT, EXPLORATORY_NAME, COMP_NAME); verifyNoMoreInteractions(computationalDAO); }
@Test public void getComputationalResourceWithException() { doThrow(new DlabException("Computational resource not found")) .when(computationalDAO).fetchComputationalFields(anyString(), anyString(), anyString(), anyString()); Optional<UserComputationalResource> expectedResource = Optional.empty(); Optional<UserComputationalResource> actualResource = computationalService.getComputationalResource(USER, PROJECT, EXPLORATORY_NAME, COMP_NAME); assertEquals(expectedResource, actualResource); verify(computationalDAO).fetchComputationalFields(USER, PROJECT, EXPLORATORY_NAME, COMP_NAME); verifyNoMoreInteractions(computationalDAO); }