@Test void canConvertToResource() { final JsonNode node = JsonNodeFactory.instance.objectNode().set("description", JsonNodeFactory.instance.textNode("blah")); final EntityModel<JsonNode> model = this.assembler.toModel(node); Assertions.assertThat(model.getLinks()).hasSize(5); Assertions.assertThat(model.getContent()).isNotNull(); Assertions.assertThat(model.getLink("self")).isNotNull(); Assertions.assertThat(model.getLink("applications")).isNotNull(); Assertions.assertThat(model.getLink("commands")).isNotNull(); Assertions.assertThat(model.getLink("clusters")).isNotNull(); Assertions.assertThat(model.getLink("jobs")).isNotNull(); }
@Override @SuppressFBWarnings("NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") @Nonnull public EntityModel<JsonNode> toModel(final JsonNode metadata) { final EntityModel<JsonNode> rootResource = new EntityModel<>(metadata); try { rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(RootRestController.class) .getRoot() ).withSelfRel() ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .createApplication(null) ).withRel(APPLICATIONS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .createCommand(null) ).withRel(COMMANDS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ClusterRestController.class) .createCluster(null) ).withRel(CLUSTERS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .submitJob(null, null, null, null) ).withRel(JOBS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return rootResource; }
RootModelAssembler implements RepresentationModelAssembler<JsonNode, EntityModel<JsonNode>> { @Override @SuppressFBWarnings("NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") @Nonnull public EntityModel<JsonNode> toModel(final JsonNode metadata) { final EntityModel<JsonNode> rootResource = new EntityModel<>(metadata); try { rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(RootRestController.class) .getRoot() ).withSelfRel() ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .createApplication(null) ).withRel(APPLICATIONS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .createCommand(null) ).withRel(COMMANDS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ClusterRestController.class) .createCluster(null) ).withRel(CLUSTERS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .submitJob(null, null, null, null) ).withRel(JOBS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return rootResource; } }
RootModelAssembler implements RepresentationModelAssembler<JsonNode, EntityModel<JsonNode>> { @Override @SuppressFBWarnings("NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") @Nonnull public EntityModel<JsonNode> toModel(final JsonNode metadata) { final EntityModel<JsonNode> rootResource = new EntityModel<>(metadata); try { rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(RootRestController.class) .getRoot() ).withSelfRel() ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .createApplication(null) ).withRel(APPLICATIONS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .createCommand(null) ).withRel(COMMANDS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ClusterRestController.class) .createCluster(null) ).withRel(CLUSTERS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .submitJob(null, null, null, null) ).withRel(JOBS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return rootResource; }  }
RootModelAssembler implements RepresentationModelAssembler<JsonNode, EntityModel<JsonNode>> { @Override @SuppressFBWarnings("NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") @Nonnull public EntityModel<JsonNode> toModel(final JsonNode metadata) { final EntityModel<JsonNode> rootResource = new EntityModel<>(metadata); try { rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(RootRestController.class) .getRoot() ).withSelfRel() ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .createApplication(null) ).withRel(APPLICATIONS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .createCommand(null) ).withRel(COMMANDS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ClusterRestController.class) .createCluster(null) ).withRel(CLUSTERS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .submitJob(null, null, null, null) ).withRel(JOBS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return rootResource; }  @Override @SuppressFBWarnings("NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") @Nonnull EntityModel<JsonNode> toModel(final JsonNode metadata); }
RootModelAssembler implements RepresentationModelAssembler<JsonNode, EntityModel<JsonNode>> { @Override @SuppressFBWarnings("NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") @Nonnull public EntityModel<JsonNode> toModel(final JsonNode metadata) { final EntityModel<JsonNode> rootResource = new EntityModel<>(metadata); try { rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(RootRestController.class) .getRoot() ).withSelfRel() ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ApplicationRestController.class) .createApplication(null) ).withRel(APPLICATIONS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(CommandRestController.class) .createCommand(null) ).withRel(COMMANDS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(ClusterRestController.class) .createCluster(null) ).withRel(CLUSTERS_LINK) ); rootResource.add( WebMvcLinkBuilder.linkTo( WebMvcLinkBuilder .methodOn(JobRestController.class) .submitJob(null, null, null, null) ).withRel(JOBS_LINK) ); } catch (final GenieException | GenieCheckedException ge) { throw new RuntimeException(ge); } return rootResource; }  @Override @SuppressFBWarnings("NP_NULL_PARAM_DEREF_ALL_TARGETS_DANGEROUS") @Nonnull EntityModel<JsonNode> toModel(final JsonNode metadata);  }