@Test public void toResourceShouldReturnResourceWithSelfLinkContainingResourceId() { ProcessDefinitionImpl processDefinition = new ProcessDefinitionImpl(); processDefinition.setId("my-identifier"); given(converter.from(processDefinition)).willReturn(new CloudProcessDefinitionImpl(processDefinition)); Resource<CloudProcessDefinition> processDefinitionResource = resourceAssembler.toResource(processDefinition); Link selfResourceLink = processDefinitionResource.getLink("self"); assertThat(selfResourceLink).isNotNull(); assertThat(selfResourceLink.getHref()).contains("my-identifier"); }
@Override public Resource<CloudProcessDefinition> toResource(ProcessDefinition processDefinition) { CloudProcessDefinition cloudProcessDefinition = converter.from(processDefinition); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(cloudProcessDefinition.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(cloudProcessDefinition, selfRel, startProcessLink, homeLink); }
ProcessDefinitionResourceAssembler implements ResourceAssembler<ProcessDefinition, Resource<CloudProcessDefinition>> { @Override public Resource<CloudProcessDefinition> toResource(ProcessDefinition processDefinition) { CloudProcessDefinition cloudProcessDefinition = converter.from(processDefinition); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(cloudProcessDefinition.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(cloudProcessDefinition, selfRel, startProcessLink, homeLink); } }
ProcessDefinitionResourceAssembler implements ResourceAssembler<ProcessDefinition, Resource<CloudProcessDefinition>> { @Override public Resource<CloudProcessDefinition> toResource(ProcessDefinition processDefinition) { CloudProcessDefinition cloudProcessDefinition = converter.from(processDefinition); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(cloudProcessDefinition.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(cloudProcessDefinition, selfRel, startProcessLink, homeLink); } ProcessDefinitionResourceAssembler(ToCloudProcessDefinitionConverter converter); }
ProcessDefinitionResourceAssembler implements ResourceAssembler<ProcessDefinition, Resource<CloudProcessDefinition>> { @Override public Resource<CloudProcessDefinition> toResource(ProcessDefinition processDefinition) { CloudProcessDefinition cloudProcessDefinition = converter.from(processDefinition); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(cloudProcessDefinition.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(cloudProcessDefinition, selfRel, startProcessLink, homeLink); } ProcessDefinitionResourceAssembler(ToCloudProcessDefinitionConverter converter); @Override Resource<CloudProcessDefinition> toResource(ProcessDefinition processDefinition); }
ProcessDefinitionResourceAssembler implements ResourceAssembler<ProcessDefinition, Resource<CloudProcessDefinition>> { @Override public Resource<CloudProcessDefinition> toResource(ProcessDefinition processDefinition) { CloudProcessDefinition cloudProcessDefinition = converter.from(processDefinition); Link selfRel = linkTo(methodOn(ProcessDefinitionControllerImpl.class).getProcessDefinition(cloudProcessDefinition.getId())).withSelfRel(); Link startProcessLink = linkTo(methodOn(ProcessInstanceControllerImpl.class).startProcess(null)).withRel("startProcess"); Link homeLink = linkTo(HomeControllerImpl.class).withRel("home"); return new Resource<>(cloudProcessDefinition, selfRel, startProcessLink, homeLink); } ProcessDefinitionResourceAssembler(ToCloudProcessDefinitionConverter converter); @Override Resource<CloudProcessDefinition> toResource(ProcessDefinition processDefinition);  }