/*
 * Copyright 2020 Global Biodiversity Information Facility (GBIF)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gbif.registry.utils.cucumber;

import org.gbif.api.model.common.GbifUser;

import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;

import io.cucumber.datatable.TableEntryTransformer;

public class GbifUserTableEntryTransformer implements TableEntryTransformer<GbifUser> {

  @Override
  public GbifUser transform(Map<String, String> entry) {
    GbifUser result = new GbifUser();
    Optional.ofNullable(entry.get("key")).map(Integer::parseInt).ifPresent(result::setKey);
    result.setUserName(entry.get("userName"));
    result.setFirstName(entry.get("firstName"));
    result.setLastName(entry.get("lastName"));
    result.setEmail(entry.get("email"));
    Optional.ofNullable(entry.get("roles"))
        .map(roles -> roles.split(","))
        .map(Arrays::asList)
        .map((Function<List<String>, HashSet>) HashSet::new)
        .ifPresent(result::setRoles);

    return result;
  }
}

@@ -869,16 +869,52 @@
 unction;
+%0Aimport java.util.stream.Collectors;
 %0A%0Aimport
@@ -1645,16 +1645,1068 @@
 oles);%0A%0A
+    Optional.ofNullable(entry.get(%22settings%22))%0A        .map(settings -%3E settings.split(%22,%22))%0A        .map(Arrays::stream)%0A        .map(%0A            keyValuePairStream -%3E%0A                keyValuePairStream%0A                    .map(keyValuePair -%3E keyValuePair.split(%22=%3E%22))%0A                    .collect(%0A                        Collectors.toMap(%0A                            keyAndValue -%3E keyAndValue%5B0%5D.trim(),%0A                            keyAndValue -%3E keyAndValue%5B1%5D.trim())))%0A        .ifPresent(result::setSettings);%0A%0A    Optional.ofNullable(entry.get(%22systemSettings%22))%0A        .map(settings -%3E settings.split(%22,%22))%0A        .map(Arrays::stream)%0A        .map(%0A            keyValuePairStream -%3E%0A                keyValuePairStream%0A                    .map(keyValuePair -%3E keyValuePair.split(%22=%3E%22))%0A                    .collect(%0A                        Collectors.toMap(%0A                            keyAndValue -%3E keyAndValue%5B0%5D.trim(),%0A                            keyAndValue -%3E keyAndValue%5B1%5D.trim())))%0A        .ifPresent(result::setSystemSettings);%0A%0A
     retu

Update GbifUserTableEntryTransformer