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

OZG-6477 OZG-6439 Allow multiple collaboration requests

parent 9a5b67de
No related branches found
No related tags found
No related merge requests found
......@@ -42,8 +42,7 @@ class CollaborationModelAssembler implements RepresentationModelAssembler<Collab
return CollectionModelBuilder.fromEntities(entityModels)
.addLink(selfLink)
.ifMatch(entityModels::isEmpty)
.addLink(() -> buildCreateCollaborationRequestLink(vorgangId))
.addLink(buildCreateCollaborationRequestLink(vorgangId))
.buildModel();
}
......
......@@ -92,10 +92,16 @@ class CollaborationModelAssemblerTest {
@Nested
class TestToCollectionModel {
private final Collaboration collaboration = FachstelleCollaborationTestFactory.create();
@Nested
class OnNonEmptyCollaborationList {
@Mock
private Link createCollaborationRequestLink;
@BeforeEach
void mock() {
doReturn(createCollaborationRequestLink).when(assembler).buildCreateCollaborationRequestLink(VorgangHeaderTestFactory.ID);
}
@Test
void shouldCallToModel() {
......@@ -122,44 +128,6 @@ class CollaborationModelAssemblerTest {
.isEqualTo(CollaborationByVorgangController.PATH + "/" + VorgangHeaderTestFactory.ID + "/collaborations");
}
@Test
void shouldNotHaveCreateCollaborationRequestLink() {
var collectionModel = callAssembler();
assertThat(collectionModel.getLink(CollaborationModelAssembler.REL_CREATE_COLLABORATION_REQUEST)).isEmpty();
}
private CollectionModel<EntityModel<Collaboration>> callAssembler() {
return assembler.toCollectionModel(Stream.of(collaboration), VorgangHeaderTestFactory.ID);
}
}
@Nested
class OnEmptyCollaborationList {
@Mock
private Link createCollaborationRequestLink;
@BeforeEach
void mock() {
doReturn(createCollaborationRequestLink).when(assembler).buildCreateCollaborationRequestLink(VorgangHeaderTestFactory.ID);
}
@Test
void shouldHaveEmptyContent() {
var collectionModel = callAssembler();
assertThat(collectionModel.getContent()).isEmpty();
}
@Test
void shouldHaveSelfLink() {
var collectionModel = callAssembler();
assertThat(collectionModel.getLink(IanaLinkRelations.SELF_VALUE)).get().extracting(Link::getHref)
.isEqualTo(CollaborationByVorgangController.PATH + "/" + VorgangHeaderTestFactory.ID + "/collaborations");
}
@Test
void shouldHaveCreateCollaborationRequestLink() {
var collectionModel = callAssembler();
......@@ -168,8 +136,7 @@ class CollaborationModelAssemblerTest {
}
private CollectionModel<EntityModel<Collaboration>> callAssembler() {
return assembler.toCollectionModel(Stream.empty(), VorgangHeaderTestFactory.ID);
}
return assembler.toCollectionModel(Stream.of(collaboration), VorgangHeaderTestFactory.ID);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment