diff --git a/src/main/java/it/gov/pagopa/pu/bff/service/broker/BrokerServiceImpl.java b/src/main/java/it/gov/pagopa/pu/bff/service/broker/BrokerServiceImpl.java index aaa7792..7ec5ee4 100644 --- a/src/main/java/it/gov/pagopa/pu/bff/service/broker/BrokerServiceImpl.java +++ b/src/main/java/it/gov/pagopa/pu/bff/service/broker/BrokerServiceImpl.java @@ -16,6 +16,7 @@ public class BrokerServiceImpl implements BrokerService { private final BrokerEntityClient brokerEntityClient; private final PersonalisationFE2ConfigFEMapper personalisationFE2ConfigFEMapper; private final DefaultConfigFe defaultConfigFe; + private final ConfigFE defaultFEConfig; public BrokerServiceImpl(BrokerEntityClient brokerEntityClient, DefaultConfigFe defaultConfigFe, @@ -23,15 +24,14 @@ public BrokerServiceImpl(BrokerEntityClient brokerEntityClient, this.brokerEntityClient = brokerEntityClient; this.defaultConfigFe = defaultConfigFe; this.personalisationFE2ConfigFEMapper = personalisationFE2ConfigFEMapper; + this.defaultFEConfig = getFEConfiguration(null); } @Override public ConfigFE getBrokerConfig(UserInfo user, String accessToken) { if (user.getBrokerId() == null) { log.warn("BrokerId is null, returning default configuration."); - ConfigFE defaultConfig = getFEConfiguration(null); - defaultConfig.setCanManageUsers(user.getCanManageUsers()); - return defaultConfig; + return this.defaultFEConfig; } log.info("BrokerId retrieved from UserInfo: {}", user.getBrokerId()); diff --git a/src/test/java/it/gov/pagopa/pu/bff/service/BrokerServiceImplTest.java b/src/test/java/it/gov/pagopa/pu/bff/service/BrokerServiceImplTest.java index 2276053..bc1ae7a 100644 --- a/src/test/java/it/gov/pagopa/pu/bff/service/BrokerServiceImplTest.java +++ b/src/test/java/it/gov/pagopa/pu/bff/service/BrokerServiceImplTest.java @@ -68,20 +68,6 @@ void givenGetBrokerConfigWhenValidDataThenOK() { assertEquals(personalisationFe.getLogoFooterImg(), result.getLogoFooterImg()); } - @Test - void givenGetBrokerConfigWhenBrokerIdIsNullThenDefaultConfig() { - UserInfo userInfo = new UserInfo(); - userInfo.setBrokerId(null); - userInfo.setCanManageUsers(false); - - Mockito.when(personalisationFE2ConfigFEMapperMock.mapPersonalisationFE2ConfigFE(defaultConfigFeMock)) - .thenReturn(defaultFEConfig); - - ConfigFE result = brokerService.getBrokerConfig(userInfo, accessToken); - - assertEquals(defaultFEConfig, result); - assertEquals(userInfo.getCanManageUsers(), result.getCanManageUsers()); - } @Test void givenGetBrokerConfigWhenBrokerNotFoundThenDefaultConfig() {