@Test void canConvertToModel() { final EntityModel<Application> model = this.assembler.toModel(this.application); Assertions.assertThat(model.getLinks()).hasSize(2); Assertions.assertThat(model.getLink("self")).isPresent(); Assertions.assertThat(model.getLink("commands")).isPresent(); }
@Override @Nonnull public EntityModel<Application> toModel(final Application application) { final String id = application.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Application> applicationModel = new EntityModel<>(application); try { applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getApplication(id) ).withSelfRel() ); applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getCommandsForApplication(id, null) ).withRel(COMMANDS_LINK) ); } catch (final GenieException | NotFoundException ge) { throw new RuntimeException(ge); } return applicationModel; }
ApplicationModelAssembler implements RepresentationModelAssembler<Application, EntityModel<Application>> { @Override @Nonnull public EntityModel<Application> toModel(final Application application) { final String id = application.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Application> applicationModel = new EntityModel<>(application); try { applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getApplication(id) ).withSelfRel() ); applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getCommandsForApplication(id, null) ).withRel(COMMANDS_LINK) ); } catch (final GenieException | NotFoundException ge) { throw new RuntimeException(ge); } return applicationModel; } }
ApplicationModelAssembler implements RepresentationModelAssembler<Application, EntityModel<Application>> { @Override @Nonnull public EntityModel<Application> toModel(final Application application) { final String id = application.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Application> applicationModel = new EntityModel<>(application); try { applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getApplication(id) ).withSelfRel() ); applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getCommandsForApplication(id, null) ).withRel(COMMANDS_LINK) ); } catch (final GenieException | NotFoundException ge) { throw new RuntimeException(ge); } return applicationModel; }  }
ApplicationModelAssembler implements RepresentationModelAssembler<Application, EntityModel<Application>> { @Override @Nonnull public EntityModel<Application> toModel(final Application application) { final String id = application.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Application> applicationModel = new EntityModel<>(application); try { applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getApplication(id) ).withSelfRel() ); applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getCommandsForApplication(id, null) ).withRel(COMMANDS_LINK) ); } catch (final GenieException | NotFoundException ge) { throw new RuntimeException(ge); } return applicationModel; }  @Override @Nonnull EntityModel<Application> toModel(final Application application); }
ApplicationModelAssembler implements RepresentationModelAssembler<Application, EntityModel<Application>> { @Override @Nonnull public EntityModel<Application> toModel(final Application application) { final String id = application.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Application> applicationModel = new EntityModel<>(application); try { applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getApplication(id) ).withSelfRel() ); applicationModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .getCommandsForApplication(id, null) ).withRel(COMMANDS_LINK) ); } catch (final GenieException | NotFoundException ge) { throw new RuntimeException(ge); } return applicationModel; }  @Override @Nonnull EntityModel<Application> toModel(final Application application);  }