Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ElisKina-dev committed Jan 13, 2025
1 parent eba2030 commit a196013
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ 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,
PersonalisationFE2ConfigFEMapper personalisationFE2ConfigFEMapper) {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit a196013

Please sign in to comment.