@Test void canConvertToResource() { final EntityModel<Command> model = this.assembler.toModel(this.command); Assertions.assertThat(model.getLinks()).hasSize(3); Assertions.assertThat(model.getLink("self")).isPresent(); Assertions.assertThat(model.getLink("applications")).isPresent(); Assertions.assertThat(model.getLink("clusters")).isPresent(); }
@Override @Nonnull public EntityModel<Command> toModel(final Command command) { final String id = command.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Command> commandModel = new EntityModel<>(command); try { commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getCommand(id) ).withSelfRel() ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getApplicationsForCommand(id) ).withRel(APPLICATIONS_LINK) ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getClustersForCommand(id, null) ).withRel(CLUSTERS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return commandModel; }
CommandModelAssembler implements RepresentationModelAssembler<Command, EntityModel<Command>> { @Override @Nonnull public EntityModel<Command> toModel(final Command command) { final String id = command.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Command> commandModel = new EntityModel<>(command); try { commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getCommand(id) ).withSelfRel() ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getApplicationsForCommand(id) ).withRel(APPLICATIONS_LINK) ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getClustersForCommand(id, null) ).withRel(CLUSTERS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return commandModel; } }
CommandModelAssembler implements RepresentationModelAssembler<Command, EntityModel<Command>> { @Override @Nonnull public EntityModel<Command> toModel(final Command command) { final String id = command.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Command> commandModel = new EntityModel<>(command); try { commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getCommand(id) ).withSelfRel() ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getApplicationsForCommand(id) ).withRel(APPLICATIONS_LINK) ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getClustersForCommand(id, null) ).withRel(CLUSTERS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return commandModel; }  }
CommandModelAssembler implements RepresentationModelAssembler<Command, EntityModel<Command>> { @Override @Nonnull public EntityModel<Command> toModel(final Command command) { final String id = command.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Command> commandModel = new EntityModel<>(command); try { commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getCommand(id) ).withSelfRel() ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getApplicationsForCommand(id) ).withRel(APPLICATIONS_LINK) ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getClustersForCommand(id, null) ).withRel(CLUSTERS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return commandModel; }  @Override @Nonnull EntityModel<Command> toModel(final Command command); }
CommandModelAssembler implements RepresentationModelAssembler<Command, EntityModel<Command>> { @Override @Nonnull public EntityModel<Command> toModel(final Command command) { final String id = command.getId().orElseThrow(IllegalArgumentException::new); final EntityModel<Command> commandModel = new EntityModel<>(command); try { commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getCommand(id) ).withSelfRel() ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getApplicationsForCommand(id) ).withRel(APPLICATIONS_LINK) ); commandModel.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .getClustersForCommand(id, null) ).withRel(CLUSTERS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return commandModel; }  @Override @Nonnull EntityModel<Command> toModel(final Command command);  }