test_class.declarator: mapper
test_class.original_string: ExpressionUserMapper mapper;
test_class.type: ExpressionUserMapper
test_class.var_name: mapper
test_class.declarator: attributeMappings
test_class.modifier: private
test_class.original_string: private Map<String, String> attributeMappings;
test_class.type: Map<String, String>
test_class.var_name: attributeMappings
test_class.declarator: SAMPLE_JSON = "{\"user_id\":\"123\",\"email\":\"myemail@email.com\"}"
test_class.original_string: String SAMPLE_JSON = "{\"user_id\":\"123\",\"email\":\"myemail@email.com\"}";
test_class.type: String
test_class.var_name: SAMPLE_JSON
test_class.file: src/core/security/src/test/java/it/geosolutions/geostore/core/security/ExpressionUserMapperTest.java
test_class.identifier: ExpressionUserMapperTest
test_case.body: @Test
      public void testUserDetailsMapping() {
          MockUserDetailsWithAttributes detailsWithAttributes =  new MockUserDetailsWithAttributes();
          mapper = new UserDetailsExpressionUserMapper(attributeMappings);
          User user = new User();
          detailsWithAttributes.getAttributes().put("sample", "mock");
          attributeMappings.put("transformed", "sample");
          mapper.mapUser(detailsWithAttributes, user);
          
          assertEquals(1, user.getAttribute().size());
          assertEquals("transformed", user.getAttribute().get(0).getName());
          assertEquals("mock", user.getAttribute().get(0).getValue());
      }
test_case.class_method_signature: ExpressionUserMapperTest.testUserDetailsMapping()
test_case.full_signature: @Test public void testUserDetailsMapping()
test_case.identifier: testUserDetailsMapping
test_case.invocations: put getAttributes put mapUser assertEquals size getAttribute assertEquals getName get getAttribute assertEquals getValue get getAttribute
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testUserDetailsMapping()
focal_class.declarator: attributeMappings
focal_class.original_string: Map<String, String> attributeMappings;
focal_class.type: Map<String, String>
focal_class.var_name: attributeMappings
focal_class.declarator: parser = new SpelExpressionParser()
focal_class.modifier: public static
focal_class.original_string: public static SpelExpressionParser parser = new SpelExpressionParser();
focal_class.type: SpelExpressionParser
focal_class.var_name: parser
focal_class.declarator: evaluationContext = new StandardEvaluationContext()
focal_class.modifier: protected
focal_class.original_string: protected StandardEvaluationContext evaluationContext = new StandardEvaluationContext();
focal_class.type: StandardEvaluationContext
focal_class.var_name: evaluationContext
focal_class.file: src/core/security/src/main/java/it/geosolutions/geostore/core/security/ExpressionUserMapper.java
focal_class.identifier: ExpressionUserMapper
focal_class.interfaces: implements UserMapper
focal_class.class_method_signature: ExpressionUserMapper.ExpressionUserMapper(Map<String, String> attributeMappings)
focal_class.full_signature: public  ExpressionUserMapper(Map<String, String> attributeMappings)
focal_class.identifier: ExpressionUserMapper
focal_class.modifiers: public
focal_class.parameters: (Map<String, String> attributeMappings)
focal_class.signature:  ExpressionUserMapper(Map<String, String> attributeMappings)
focal_class.class_method_signature: ExpressionUserMapper.mapUser(Object details, User user)
focal_class.full_signature: @Override /** * If details is a UserDetailsWithAttributes object, its attributes are mapped to User * attributes. * Each mapping is an SpEL expression using the UserDetailsWithAttributes as a source. * */ public void mapUser(Object details, User user)
focal_class.identifier: mapUser
focal_class.modifiers: @Override /** * If details is a UserDetailsWithAttributes object, its attributes are mapped to User * attributes. * Each mapping is an SpEL expression using the UserDetailsWithAttributes as a source. * */ public
focal_class.parameters: (Object details, User user)
focal_class.return: void
focal_class.signature: void mapUser(Object details, User user)
focal_class.class_method_signature: ExpressionUserMapper.preProcessDetails(Object details)
focal_class.full_signature: protected Object preProcessDetails(Object details)
focal_class.identifier: preProcessDetails
focal_class.modifiers: protected
focal_class.parameters: (Object details)
focal_class.return: Object
focal_class.signature: Object preProcessDetails(Object details)
focal_method.body: @Override
      /**
       * If details is a UserDetailsWithAttributes object, its attributes are mapped to User
       * attributes.
       * Each mapping is an SpEL expression using the UserDetailsWithAttributes as a source.
       * 
       */
      public void mapUser(Object details, User user) {
          List<UserAttribute> attributes = new ArrayList<UserAttribute>();
          details = preProcessDetails(details);
          for(String attributeName : attributeMappings.keySet()) {
              
              Expression exp = parser.parseExpression(attributeMappings.get(attributeName));
              UserAttribute userAttribute = new UserAttribute();
              userAttribute.setName(attributeName);
              Object value = exp.getValue(evaluationContext, details);
              userAttribute.setValue(value == null ? null : value.toString());
              attributes.add(userAttribute);
          }
          user.setAttribute(attributes);
          
      }
focal_method.class_method_signature: ExpressionUserMapper.mapUser(Object details, User user)
focal_method.full_signature: @Override /** * If details is a UserDetailsWithAttributes object, its attributes are mapped to User * attributes. * Each mapping is an SpEL expression using the UserDetailsWithAttributes as a source. * */ public void mapUser(Object details, User user)
focal_method.identifier: mapUser
focal_method.invocations: preProcessDetails keySet parseExpression get setName getValue setValue toString add setAttribute
focal_method.modifiers: @Override /** * If details is a UserDetailsWithAttributes object, its attributes are mapped to User * attributes. * Each mapping is an SpEL expression using the UserDetailsWithAttributes as a source. * */ public
focal_method.parameters: (Object details, User user)
focal_method.return: void
focal_method.signature: void mapUser(Object details, User user)