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

OZG-6867 OZG-6905 add relation to organisationseinheiten

parent db4e6218
No related branches found
No related tags found
No related merge requests found
package de.ozgcloud.admin.organisationseinheit;
import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.EntityModel;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import lombok.RequiredArgsConstructor;
@RestController
@RequestMapping(OrganisationsEinheitController.PATH)
@RequiredArgsConstructor
class OrganisationsEinheitController {
static final String PATH = "/api/organisationseinheits"; // NOSONAR
public CollectionModel<EntityModel<OrganisationsEinheit>> getAll(){
throw new UnsupportedOperationException("Not implemented yet");
}
}
package de.ozgcloud.admin.organisationseinheit;
import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.*;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.server.RepresentationModelProcessor;
import org.springframework.stereotype.Component;
import de.ozgcloud.admin.Root;
@Component
class OrganisationsEinheitRootProcessor implements RepresentationModelProcessor<EntityModel<Root>> {
static final String REL_ORGANISATIONS_EINHEITEN = "organisationsEinheiten";
@Override
public EntityModel<Root> process(EntityModel<Root> model) {
return model.add(linkTo(methodOn(OrganisationsEinheitController.class).getAll()).withRel(REL_ORGANISATIONS_EINHEITEN));
}
}
package de.ozgcloud.admin.organisationseinheit;
import static org.assertj.core.api.Assertions.*;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.springframework.hateoas.EntityModel;
import org.springframework.hateoas.Link;
import de.ozgcloud.admin.RootTestFactory;
class OrganisationsEinheitRootProcessorTest {
@InjectMocks
private OrganisationsEinheitRootProcessor organisationsEinheitRootProcessor;
@Nested
class TestProcess {
@Nested
class OrganisationsEinheitenLinkRelation {
@Test
void shouldExists() {
var model = organisationsEinheitRootProcessor.process(EntityModel.of(RootTestFactory.create()));
assertThat(model.getLink(OrganisationsEinheitRootProcessor.REL_ORGANISATIONS_EINHEITEN)).isNotEmpty();
}
@Test
void shouldHaveHref() {
var model = organisationsEinheitRootProcessor.process(EntityModel.of(RootTestFactory.create()));
assertThat(model.getLink(OrganisationsEinheitRootProcessor.REL_ORGANISATIONS_EINHEITEN))
.get()
.extracting(Link::getHref)
.isEqualTo(OrganisationsEinheitController.PATH);
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment