<commit_before>package com.github.kongchen.swagger.docgen.reader;

import io.swagger.models.Path;
import io.swagger.models.Swagger;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.HashSet;
import java.util.Map;

import static java.util.Collections.singletonList;

public class SpringMvcApiReaderTest {

    @Test
    public void testReadWithEmptyPathOnMethodLevel() throws Exception {

        Log log = new SystemStreamLog();

        SpringMvcApiReader springMvcApiReader = new SpringMvcApiReader(null, log);
        Swagger swagger = springMvcApiReader.read(new HashSet<>(singletonList(ExampleController.class)));

        Map<String, Path> paths = swagger.getPaths();

        Assert.assertTrue(paths.keySet().contains("/api"));
        Assert.assertEquals(paths.get("/api").getGet().getOperationId(), "emptyPathEndpoint");

        Assert.assertTrue(paths.keySet().contains("/api/someendpoint"));
        Assert.assertEquals(paths.get("/api/someendpoint").getGet().getOperationId(), "someEndpoint");
    }


    @RestController
    @RequestMapping("/api")
    static class ExampleController {

        @GetMapping("someendpoint")
        public void someEndpoint() {

        }

        @GetMapping("")
        public void emptyPathEndpoint() {

        }
    }

}<commit_msg>add testApiOperationNickname<commit_after>package com.github.kongchen.swagger.docgen.reader;

import io.swagger.annotations.ApiOperation;
import io.swagger.models.Path;
import io.swagger.models.Swagger;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.HashSet;
import java.util.Map;

import static java.util.Collections.singletonList;

public class SpringMvcApiReaderTest {

    private final Log log = new SystemStreamLog();

    @Test
    public void testReadWithEmptyPathOnMethodLevel() throws Exception {

        SpringMvcApiReader springMvcApiReader = new SpringMvcApiReader(null, log);
        Swagger swagger = springMvcApiReader.read(new HashSet<>(singletonList(ExampleController.class)));

        Map<String, Path> paths = swagger.getPaths();

        Assert.assertTrue(paths.keySet().contains("/api"));
        Assert.assertEquals(paths.get("/api").getGet().getOperationId(), "emptyPathEndpoint");

        Assert.assertTrue(paths.keySet().contains("/api/someendpoint"));
        Assert.assertEquals(paths.get("/api/someendpoint").getGet().getOperationId(), "someEndpoint");
    }


    @Test
    public void testApiOperationNickname() throws Exception {

        SpringMvcApiReader springMvcApiReader = new SpringMvcApiReader(null, log);
        Swagger swagger = springMvcApiReader.read(new HashSet<>(singletonList(ExampleController.class)));

        Path path = swagger.getPaths().get("/api/endpoint-with-nickname");
        Assert.assertEquals(path.getGet().getOperationId(), "nicknamed");
    }


    @RestController
    @RequestMapping("/api")
    static class ExampleController {

        @GetMapping("someendpoint")
        public void someEndpoint() {

        }

        @GetMapping("")
        public void emptyPathEndpoint() {

        }

        @GetMapping("endpoint-with-nickname")
        @ApiOperation(nickname = "nicknamed", value = "")
        public void endpointWithNickname() {

        }
    }

}
{'fraction_non_alphanumeric': 0.11960478419136765, 'fraction_numerical': 0.0, 'mean_word_length': 4.02875816993464, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5110730', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1052, 'n_words': 176}