### Question:
ConfigurationService { public Map<String, Object> getConfigByUser(final long userId) { final List<BConfiguration> configs = configurationRepository.findAllByUserId(userId); Map<String, Object> map = new HashMap<>(); for (BConfiguration c : configs) { map.put(c.getKey(), c.getValue()); } return map; } @Autowired  ConfigurationService(final BConfigurationRepository configurationRepository,
                                final EUserRepository userRepository, final EOwnedEntityRepository entityRepository,
                                final BRoleRepository roleRepository, final BAuthorizationRepository authRepository,
                                final DefaultConst defaultConst); boolean isApplicationConfigured(); boolean isDefaultConfigurationCreated(); boolean isDefaultUserAssignedToEntityWithRole(); Map<String, String> getConfig(); Object getConfig(final String key); String getConfig(final String key, final long userId); Map<String, Object> getConfigByUser(final long userId); void saveConfig(final Map<String, Object> configs); void saveConfig(final Map<String, Object> configs, final long userId); void setUserRegistrationAllowed(final boolean userRegistrationAllowed); void setIsMultiEntity(final boolean isMultiEntity); Long getLastAccessedEntityIdByUser(final long userId); void setLastAccessedEntityIdByUser(final long userId, final long entityId); static final String IN_SERVER; static final String CONFIG_NOT_FOUND; }### Answer:
@Test public void getConfigByUser() { EUser u = userRepository.save(EntityUtil.getSampleUser(random.nextString())); assertNotNull(u); EOwnedEntity e = entityRepository.save(EntityUtil.getSampleEntity(random.nextString())); assertNotNull(e); BConfiguration c = configurationRepository.save(new BConfiguration(keyLang, "es", u.getId())); assertNotNull(c); BConfiguration c2 = configurationRepository.save( new BConfiguration(keyLastAccessedEntity, String.valueOf(e.getId()), u.getId()) ); assertNotNull(c2); Map<String, Object> configs = configurationService.getConfigByUser(u.getId()); assertNotNull(configs.get(keyLang)); assertNotNull(configs.get(keyLastAccessedEntity)); assertEquals("Configuration values (language) do not match", "es", configs.get(keyLang)); assertEquals("Configuration values (last accessed entity) do not match", configs.get(keyLastAccessedEntity), String.valueOf(e.getId())); }