@Test public void creating_a_job_sets_current_user_as_owner() { PDSJobConfiguration configuration = new PDSJobConfiguration(); PDSJobCreateResult result = serviceToTest.createJob(configuration); assertNotNull(result); ArgumentCaptor<PDSJob> jobCaptor = ArgumentCaptor.forClass(PDSJob.class); verify(repository).save(jobCaptor.capture()); assertEquals("callerName", jobCaptor.getValue().getOwner()); }
@UseCaseUserCreatesJob(@PDSStep(name="service call",description = "job will be created, serverId will be used to store new job",number=2)) public PDSJobCreateResult createJob(PDSJobConfiguration configuration) { configurationValidator.assertPDSConfigurationValid(configuration); PDSJob job = new PDSJob(); job.created = LocalDateTime.now(); job.state = PDSJobStatusState.CREATED; job.owner = userContextService.getUserId(); job.setServerId(serverConfigurationService.getServerId()); try { job.jsonConfiguration=configuration.toJSON(); } catch (PDSJSONConverterException e) { throw new PDSNotAcceptableException("Configuration conversion failure:"+e.getMessage()); } job = repository.save(job); return new PDSJobCreateResult(job.getUUID()); }
PDSCreateJobService { @UseCaseUserCreatesJob(@PDSStep(name="service call",description = "job will be created, serverId will be used to store new job",number=2)) public PDSJobCreateResult createJob(PDSJobConfiguration configuration) { configurationValidator.assertPDSConfigurationValid(configuration); PDSJob job = new PDSJob(); job.created = LocalDateTime.now(); job.state = PDSJobStatusState.CREATED; job.owner = userContextService.getUserId(); job.setServerId(serverConfigurationService.getServerId()); try { job.jsonConfiguration=configuration.toJSON(); } catch (PDSJSONConverterException e) { throw new PDSNotAcceptableException("Configuration conversion failure:"+e.getMessage()); } job = repository.save(job); return new PDSJobCreateResult(job.getUUID()); } }
PDSCreateJobService { @UseCaseUserCreatesJob(@PDSStep(name="service call",description = "job will be created, serverId will be used to store new job",number=2)) public PDSJobCreateResult createJob(PDSJobConfiguration configuration) { configurationValidator.assertPDSConfigurationValid(configuration); PDSJob job = new PDSJob(); job.created = LocalDateTime.now(); job.state = PDSJobStatusState.CREATED; job.owner = userContextService.getUserId(); job.setServerId(serverConfigurationService.getServerId()); try { job.jsonConfiguration=configuration.toJSON(); } catch (PDSJSONConverterException e) { throw new PDSNotAcceptableException("Configuration conversion failure:"+e.getMessage()); } job = repository.save(job); return new PDSJobCreateResult(job.getUUID()); }  }
PDSCreateJobService { @UseCaseUserCreatesJob(@PDSStep(name="service call",description = "job will be created, serverId will be used to store new job",number=2)) public PDSJobCreateResult createJob(PDSJobConfiguration configuration) { configurationValidator.assertPDSConfigurationValid(configuration); PDSJob job = new PDSJob(); job.created = LocalDateTime.now(); job.state = PDSJobStatusState.CREATED; job.owner = userContextService.getUserId(); job.setServerId(serverConfigurationService.getServerId()); try { job.jsonConfiguration=configuration.toJSON(); } catch (PDSJSONConverterException e) { throw new PDSNotAcceptableException("Configuration conversion failure:"+e.getMessage()); } job = repository.save(job); return new PDSJobCreateResult(job.getUUID()); }  @UseCaseUserCreatesJob(@PDSStep(name="service call",description = "job will be created, serverId will be used to store new job",number=2)) PDSJobCreateResult createJob(PDSJobConfiguration configuration); }
PDSCreateJobService { @UseCaseUserCreatesJob(@PDSStep(name="service call",description = "job will be created, serverId will be used to store new job",number=2)) public PDSJobCreateResult createJob(PDSJobConfiguration configuration) { configurationValidator.assertPDSConfigurationValid(configuration); PDSJob job = new PDSJob(); job.created = LocalDateTime.now(); job.state = PDSJobStatusState.CREATED; job.owner = userContextService.getUserId(); job.setServerId(serverConfigurationService.getServerId()); try { job.jsonConfiguration=configuration.toJSON(); } catch (PDSJSONConverterException e) { throw new PDSNotAcceptableException("Configuration conversion failure:"+e.getMessage()); } job = repository.save(job); return new PDSJobCreateResult(job.getUUID()); }  @UseCaseUserCreatesJob(@PDSStep(name="service call",description = "job will be created, serverId will be used to store new job",number=2)) PDSJobCreateResult createJob(PDSJobConfiguration configuration);  }