@Test public void toResourceShouldReturnResourceWithSelfLinkContainingResourceId() { ProcessDefinitionMeta model = mock(ProcessDefinitionMeta.class); when(model.getId()).thenReturn("my-identifier"); Resource<ProcessDefinitionMeta> resource = resourceAssembler.toResource(model); Link selfResourceLink = resource.getLink("self"); assertThat(selfResourceLink).isNotNull(); assertThat(selfResourceLink.getHref()).contains("my-identifier"); Link metaResourceLink = resource.getLink("meta"); assertThat(metaResourceLink).isNotNull(); assertThat(metaResourceLink.getHref()).contains("my-identifier"); }
@Override public Resource<ProcessDefinitionMeta> toResource(ProcessDefinitionMeta processDefinitionMeta) { Link metadata = linkTo(methodOn(ProcessDefinitionMetaControllerImpl.class).getProcessDefinitionMetadata(processDefinitionMeta.getId())).withRel("meta"); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(processDefinitionMeta.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(processDefinitionMeta, metadata, selfRel, startProcessLink, homeLink); }
ProcessDefinitionMetaResourceAssembler implements ResourceAssembler<ProcessDefinitionMeta, Resource<ProcessDefinitionMeta>> { @Override public Resource<ProcessDefinitionMeta> toResource(ProcessDefinitionMeta processDefinitionMeta) { Link metadata = linkTo(methodOn(ProcessDefinitionMetaControllerImpl.class).getProcessDefinitionMetadata(processDefinitionMeta.getId())).withRel("meta"); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(processDefinitionMeta.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(processDefinitionMeta, metadata, selfRel, startProcessLink, homeLink); } }
ProcessDefinitionMetaResourceAssembler implements ResourceAssembler<ProcessDefinitionMeta, Resource<ProcessDefinitionMeta>> { @Override public Resource<ProcessDefinitionMeta> toResource(ProcessDefinitionMeta processDefinitionMeta) { Link metadata = linkTo(methodOn(ProcessDefinitionMetaControllerImpl.class).getProcessDefinitionMetadata(processDefinitionMeta.getId())).withRel("meta"); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(processDefinitionMeta.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(processDefinitionMeta, metadata, selfRel, startProcessLink, homeLink); }  }
ProcessDefinitionMetaResourceAssembler implements ResourceAssembler<ProcessDefinitionMeta, Resource<ProcessDefinitionMeta>> { @Override public Resource<ProcessDefinitionMeta> toResource(ProcessDefinitionMeta processDefinitionMeta) { Link metadata = linkTo(methodOn(ProcessDefinitionMetaControllerImpl.class).getProcessDefinitionMetadata(processDefinitionMeta.getId())).withRel("meta"); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(processDefinitionMeta.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(processDefinitionMeta, metadata, selfRel, startProcessLink, homeLink); }  @Override Resource<ProcessDefinitionMeta> toResource(ProcessDefinitionMeta processDefinitionMeta); }
ProcessDefinitionMetaResourceAssembler implements ResourceAssembler<ProcessDefinitionMeta, Resource<ProcessDefinitionMeta>> { @Override public Resource<ProcessDefinitionMeta> toResource(ProcessDefinitionMeta processDefinitionMeta) { Link metadata = linkTo(methodOn(ProcessDefinitionMetaControllerImpl.class).getProcessDefinitionMetadata(processDefinitionMeta.getId())).withRel("meta"); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(processDefinitionMeta.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(processDefinitionMeta, metadata, selfRel, startProcessLink, homeLink); }  @Override Resource<ProcessDefinitionMeta> toResource(ProcessDefinitionMeta processDefinitionMeta);  }