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

OZG-5294: remove method

parent 43725186
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ import de.ozgcloud.alfa.common.FeatureToggleProperties;
import de.ozgcloud.alfa.common.ModelBuilder;
import de.ozgcloud.alfa.common.command.CommandController.CommandByRelationController;
import de.ozgcloud.alfa.common.user.CurrentUserService;
import de.ozgcloud.alfa.common.user.UserRole;
import de.ozgcloud.alfa.vorgang.Vorgang;
import de.ozgcloud.alfa.vorgang.VorgangWithEingang;
import lombok.RequiredArgsConstructor;
......@@ -35,7 +36,7 @@ class BescheidVorgangProcessor implements RepresentationModelProcessor<EntityMod
@Override
public EntityModel<VorgangWithEingang> process(EntityModel<VorgangWithEingang> model) {
var vorgang = model.getContent();
if (Objects.isNull(vorgang) || currentUserService.isCurrentUserEinheitlicherAnsprechpartner()) {
if (Objects.isNull(vorgang) || currentUserService.hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER)) {
return model;
}
return ModelBuilder.fromModel(model)
......
......@@ -60,10 +60,6 @@ public class CurrentUserService {
return CurrentUserHelper.hasRole(role) || hasRoleReachable(role);
}
public boolean isCurrentUserEinheitlicherAnsprechpartner() {
return hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER);
}
private boolean hasRoleReachable(String role) {
var reachableRoles = roleHierarchy.getReachableGrantedAuthorities(getAuthorities());
......
......@@ -23,6 +23,7 @@ import org.springframework.hateoas.Link;
import de.ozgcloud.alfa.common.FeatureToggleProperties;
import de.ozgcloud.alfa.common.UserProfileUrlProvider;
import de.ozgcloud.alfa.common.user.CurrentUserService;
import de.ozgcloud.alfa.common.user.UserRole;
import de.ozgcloud.alfa.vorgang.Vorgang;
import de.ozgcloud.alfa.vorgang.VorgangHeaderTestFactory;
import de.ozgcloud.alfa.vorgang.VorgangWithEingang;
......@@ -60,7 +61,7 @@ class BescheidVorgangProcessorTest {
@Test
void shouldReturnTheSameModelWhenUserIsEinheitlicherAnsprechpartner() {
var inputModel = EntityModel.of(VorgangWithEingangTestFactory.create());
when(currentUserService.isCurrentUserEinheitlicherAnsprechpartner()).thenReturn(true);
when(currentUserService.hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER)).thenReturn(true);
var processedModel = processor.process(inputModel);
......
......@@ -139,35 +139,4 @@ class CurrentUserServiceTest {
}
}
}
@Nested
class TestICurrentUserEinheitlicherAnsprechpartner {
@Test
void shouldCheckRole() {
doReturn(false).when(service).hasRole(any());
service.isCurrentUserEinheitlicherAnsprechpartner();
verify(service).hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER);
}
@Test
void shouldReturnTrue() {
doReturn(true).when(service).hasRole(UserRole.EINHEITLICHER_ANSPRECHPARTNER);
var isEinhetlicherAnsprechpartner = service.isCurrentUserEinheitlicherAnsprechpartner();
assertThat(isEinhetlicherAnsprechpartner).isTrue();
}
@Test
void shouldReturnFalse() {
doReturn(false).when(service).hasRole(any());
var isEinhetlicherAnsprechpartner = service.isCurrentUserEinheitlicherAnsprechpartner();
assertThat(isEinhetlicherAnsprechpartner).isFalse();
}
}
}
\ 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