Skip to content
Snippets Groups Projects
Commit cd9735f5 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6676 OZG-6878 add link relation for searching a fachstelle

parent a5176cbe
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@ class CollaborationVorgangProcessor implements RepresentationModelProcessor<Enti
static final LinkRelation REL_COLLABORATIONS = LinkRelation.of("collaborations");
static final LinkRelation REL_SEARCH_ORGANISATIONS_EINHEIT = LinkRelation.of("searchOrganisationsEinheit");
static final LinkRelation REL_SEARCH_FACHSTELLE = LinkRelation.of("searchFachstelle");
private final CurrentUserService currentUserService;
private final CollaborationService collaborationService;
......@@ -35,9 +36,13 @@ class CollaborationVorgangProcessor implements RepresentationModelProcessor<Enti
return model;
}
var searchOrgnisationsEinheitLink = linkTo(methodOn(OrganisationsEinheitController.class).search(null)).withRel(
REL_SEARCH_ORGANISATIONS_EINHEIT);
var searchFachstelleLink = linkTo(methodOn(FachstelleController.class).search(null)).withRel(REL_SEARCH_FACHSTELLE);
return ModelBuilder.fromModel(model)
.ifMatch(() -> !collaborationService.hasCollaboration(vorgang.getId()))
.addLink(linkTo(methodOn(OrganisationsEinheitController.class).search(null)).withRel(REL_SEARCH_ORGANISATIONS_EINHEIT))
.addLinks(searchOrgnisationsEinheitLink, searchFachstelleLink)
.addLink(linkTo(methodOn(CollaborationController.class).getAllByVorgangId(vorgang.getId())).withRel(REL_COLLABORATIONS))
.buildModel();
}
......
package de.ozgcloud.alfa.collaboration;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Builder;
import lombok.Getter;
@Builder
@Getter
class Fachstelle {
@JsonIgnore
private String id;
}
package de.ozgcloud.alfa.collaboration;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.EntityModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import lombok.RequiredArgsConstructor;
@RestController
@RequestMapping(FachstelleController.PATH)
@RequiredArgsConstructor
class FachstelleController {
static final String PATH = "/api/fachstelles"; // NOSONAR
static final String SEARCH_BY_PARAM = "searchBy";
@GetMapping(params = { SEARCH_BY_PARAM })
public CollectionModel<EntityModel<Fachstelle>> search(@RequestParam String searchBy) {
return null;
}
}
......@@ -124,8 +124,7 @@ class CollaborationVorgangProcessorTest {
void shouldHaveThreeLinks() {
var model = callProcessor();
assertThat(model.getLinks()).hasSize(3);
assertThat(model.getLinks()).hasSize(4);
}
@Test
......@@ -141,6 +140,19 @@ class CollaborationVorgangProcessorTest {
.isEqualTo(expectedHref);
}
@Test
void shouldAddSearchFachstelleLink() {
var expectedHref = UriComponentsBuilder.fromUriString(FachstelleController.PATH)
.queryParam(FachstelleController.SEARCH_BY_PARAM, "{" + FachstelleController.SEARCH_BY_PARAM + "}")
.build().toString();
var model = callProcessor();
assertThat(model.getLink(CollaborationVorgangProcessor.REL_SEARCH_FACHSTELLE)).get()
.extracting(Link::getHref)
.isEqualTo(expectedHref);
}
@Test
void shouldAddCollaborationsLink() {
var expectedHref = UriComponentsBuilder.fromUriString(CollaborationController.PATH)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment