@Test public void canConvertToModel() { final EntityModel<Job> model = this.assembler.toModel(this.job); Assertions.assertThat(model.getLinks()).hasSize(9); Assertions.assertThat(model.getLink("self")).isPresent(); Assertions.assertThat(model.getLink("output")).isPresent(); Assertions.assertThat(model.getLink("request")).isPresent(); Assertions.assertThat(model.getLink("execution")).isPresent(); Assertions.assertThat(model.getLink("metadata")).isPresent(); Assertions.assertThat(model.getLink("status")).isPresent(); Assertions.assertThat(model.getLink("cluster")).isPresent(); Assertions.assertThat(model.getLink("command")).isPresent(); Assertions.assertThat(model.getLink("applications")).isPresent(); }
@Override @Nonnull public EntityModel<Job> toModel(final Job job) { final String id = job.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Job> jobModel = new EntityModel<>(job); try { jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJob(id) ).withSelfRel() ); jobModel.add( WebMvcLinkBuilder .linkTo(JobRestController.class) .slash(id) .slash(OUTPUT_LINK) .withRel(OUTPUT_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobRequest(id) ).withRel(REQUEST_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobExecution(id) ).withRel(EXECUTION_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobMetadata(id) ).withRel(METADATA_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobStatus(id) ).withRel(STATUS_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCluster(id) ).withRel(CLUSTER_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCommand(id) ).withRel(COMMAND_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobApplications(id) ).withRel(APPLICATIONS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return jobModel; }
JobModelAssembler implements RepresentationModelAssembler<Job, EntityModel<Job>> { @Override @Nonnull public EntityModel<Job> toModel(final Job job) { final String id = job.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Job> jobModel = new EntityModel<>(job); try { jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJob(id) ).withSelfRel() ); jobModel.add( WebMvcLinkBuilder .linkTo(JobRestController.class) .slash(id) .slash(OUTPUT_LINK) .withRel(OUTPUT_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobRequest(id) ).withRel(REQUEST_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobExecution(id) ).withRel(EXECUTION_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobMetadata(id) ).withRel(METADATA_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobStatus(id) ).withRel(STATUS_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCluster(id) ).withRel(CLUSTER_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCommand(id) ).withRel(COMMAND_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobApplications(id) ).withRel(APPLICATIONS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return jobModel; } }
JobModelAssembler implements RepresentationModelAssembler<Job, EntityModel<Job>> { @Override @Nonnull public EntityModel<Job> toModel(final Job job) { final String id = job.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Job> jobModel = new EntityModel<>(job); try { jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJob(id) ).withSelfRel() ); jobModel.add( WebMvcLinkBuilder .linkTo(JobRestController.class) .slash(id) .slash(OUTPUT_LINK) .withRel(OUTPUT_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobRequest(id) ).withRel(REQUEST_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobExecution(id) ).withRel(EXECUTION_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobMetadata(id) ).withRel(METADATA_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobStatus(id) ).withRel(STATUS_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCluster(id) ).withRel(CLUSTER_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCommand(id) ).withRel(COMMAND_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobApplications(id) ).withRel(APPLICATIONS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return jobModel; }  }
JobModelAssembler implements RepresentationModelAssembler<Job, EntityModel<Job>> { @Override @Nonnull public EntityModel<Job> toModel(final Job job) { final String id = job.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Job> jobModel = new EntityModel<>(job); try { jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJob(id) ).withSelfRel() ); jobModel.add( WebMvcLinkBuilder .linkTo(JobRestController.class) .slash(id) .slash(OUTPUT_LINK) .withRel(OUTPUT_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobRequest(id) ).withRel(REQUEST_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobExecution(id) ).withRel(EXECUTION_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobMetadata(id) ).withRel(METADATA_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobStatus(id) ).withRel(STATUS_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCluster(id) ).withRel(CLUSTER_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCommand(id) ).withRel(COMMAND_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobApplications(id) ).withRel(APPLICATIONS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return jobModel; }  @Override @Nonnull EntityModel<Job> toModel(final Job job); }
JobModelAssembler implements RepresentationModelAssembler<Job, EntityModel<Job>> { @Override @Nonnull public EntityModel<Job> toModel(final Job job) { final String id = job.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Job> jobModel = new EntityModel<>(job); try { jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJob(id) ).withSelfRel() ); jobModel.add( WebMvcLinkBuilder .linkTo(JobRestController.class) .slash(id) .slash(OUTPUT_LINK) .withRel(OUTPUT_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobRequest(id) ).withRel(REQUEST_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobExecution(id) ).withRel(EXECUTION_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobMetadata(id) ).withRel(METADATA_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobStatus(id) ).withRel(STATUS_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCluster(id) ).withRel(CLUSTER_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobCommand(id) ).withRel(COMMAND_LINK) ); jobModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .getJobApplications(id) ).withRel(APPLICATIONS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return jobModel; }  @Override @Nonnull EntityModel<Job> toModel(final Job job);  }