Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two identical integration tests. #2728

Open
ancavar opened this issue Dec 19, 2023 · 0 comments
Open

Two identical integration tests. #2728

ancavar opened this issue Dec 19, 2023 · 0 comments
Labels
ctg-bug Issue is a bug

Comments

@ancavar
Copy link

ancavar commented Dec 19, 2023

To Reproduce
Generate integration tests for controller's method which has @PreAuthorize, e.g.

    @GetMapping("/demo")
    @PreAuthorize("hasAuthority('write')")
    public String demo() {
        return "demo";
    }

Expected behavior

Only one such test is expected.

Actual behavior

    @Test
    @DisplayName("demo: ")
    public void testDemo() throws Exception {
        Object[] uriVariables = {};
        MockHttpServletRequestBuilder mockHttpServletRequestBuilder = get("/demo", uriVariables);

        ResultActions actual = mockMvc.perform(mockHttpServletRequestBuilder);

        actual.andDo(print());
        actual.andExpect((status()).is(403));
        actual.andExpect((content()).string(""));
    }

    /**
     * @utbot.classUnderTest {@link NameController}
     * @utbot.methodUnderTest {@link NameController#demo()}
     */
    @Test
    @DisplayName("demo: ")
    public void testDemo1() throws Exception {
        Object[] uriVariables = {};
        MockHttpServletRequestBuilder mockHttpServletRequestBuilder = get("/demo", uriVariables);

        ResultActions actual = mockMvc.perform(mockHttpServletRequestBuilder);

        actual.andDo(print());
        actual.andExpect((status()).is(403));
        actual.andExpect((content()).string(""));
    }
@ancavar ancavar added the ctg-bug Issue is a bug label Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ctg-bug Issue is a bug
Projects
Status: Todo
Development

No branches or pull requests

1 participant