<commit_before>/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * 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 io.gravitee.admin.api.resources;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.UUID;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.springframework.stereotype.Component;

import io.gravitee.common.http.HttpStatusCode;
import io.gravitee.model.User;

/**
 * Defines the REST resources to manage {@code User}.
 *
 * @author <NAME> (azize dot elamrani at gmail dot com)
 */
@Component
@Produces(MediaType.APPLICATION_JSON)
@Path("/users")
public class UserResource {

    @GET
    public Response listAll() {
        final List<String> firstNames = new ArrayList<>(Arrays.asList("Azize", "Nicolas", "David", "Loïc", "Aurélien", "Jeoffrey", "Emmanuel",
            "Yves", "Francis", "Elton"));
        final List<String> lastNames = new ArrayList<>(Arrays.asList("Elamrani", "Géraud", "Brassely", "Dassonville", "Bourdon", "Hayaert", "Péru",
            "Fourré", "Laline", "John"));
        final Random random = new Random(System.currentTimeMillis());
        final List<User> users = new ArrayList<>();
        for (int i = 1; i <= 10; i++) {
            final User user = new User();
            user.setCode(UUID.randomUUID().toString());
            int randomIndex = random.nextInt(11);
            final int firstNameIndex = randomIndex > firstNames.size() - 1 ? firstNames.size() - 1 : randomIndex;
            user.setFirstName(firstNames.remove(firstNameIndex));
            randomIndex = random.nextInt(11);
            final int lastNameIndex = randomIndex > lastNames.size() - 1 ? lastNames.size() - 1 : randomIndex;
            user.setLastName(lastNames.remove(lastNameIndex));
            users.add(user);
        }
        return Response.status(HttpStatusCode.OK_200).entity(users)
            .header("Access-Control-Allow-Origin", "*").build();
    }

    @GET
    @Path("{id}/teams")<commit_msg>feat(user): Init user resource with mocks<commit_after>/**
 * Copyright (C) 2015 The Gravitee team (http://gravitee.io)
 *
 * 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 io.gravitee.admin.api.resources;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.UUID;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.springframework.stereotype.Component;

import io.gravitee.common.http.HttpStatusCode;
import io.gravitee.model.User;

/**
 * Defines the REST resources to manage {@code User}.
 *
 * @author <NAME> (azize dot elamrani at gmail dot com)
 */
@Component
@Produces(MediaType.APPLICATION_JSON)
@Path("/users")
public class UserResource {

    @GET
    public Response listAll() {
        final List<String> firstNames = new ArrayList<>(Arrays.asList("Azize", "Nicolas", "David", "Loïc", "Aurélien", "Jeoffrey", "Emmanuel",
            "Yves", "Francis", "Elton"));
        final List<String> lastNames = new ArrayList<>(Arrays.asList("Elamrani", "Géraud", "Brassely", "Dassonville", "Bourdon", "Hayaert", "Péru",
            "Fourré", "Laline", "John"));
        final Random random = new Random(System.currentTimeMillis());
        final List<User> users = new ArrayList<>();
        for (int i = 1; i <= 10; i++) {
            final User user = new User();
            user.setCode(UUID.randomUUID().toString());
            int randomIndex = random.nextInt(11);
            final int firstNameIndex = randomIndex > firstNames.size() - 1 ? firstNames.size() - 1 : randomIndex;
            user.setFirstName(firstNames.remove(firstNameIndex));
            randomIndex = random.nextInt(11);
            final int lastNameIndex = randomIndex > lastNames.size() - 1 ? lastNames.size() - 1 : randomIndex;
            user.setLastName(lastNames.remove(lastNameIndex));
            user.setEmail(user.getFirstName().toLowerCase() + '.' + user.getLastName().toLowerCase() + "@gravitee.io");
            users.add(user);
        }
        return Response.status(HttpStatusCode.OK_200).entity(users)
            .header("Access-Control-Allow-Origin", "*").build();
    }

    @GET
    @Path("{id}/teams")
{'fraction_non_alphanumeric': 0.13288614938361132, 'fraction_numerical': 0.007976794778825236, 'mean_word_length': 3.3440944881889765, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7391002', 'n_tokens_mistral': 1669, 'n_tokens_neox': 1648, 'n_words': 459}