-
Notifications
You must be signed in to change notification settings - Fork 475
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
Controller returns links
and not _links
and much more (see body).
#1572
Comments
This suspiciously looks like you're not causing the HAL rendering to be active. It's hard to tell what causes this without further information because it could be the server set up, the test setup, the setup of the request being executed etc. Can you provide a minimal example project that reproduces the error? |
@WebMvcTest({Oauth2.class})
public class Oauth2ControllerTest {
public MockMvc mvc;
@BeforeEach
public void setup(WebApplicationContext wac) {
mvc = MockMvcBuilders.webAppContextSetup(wac)
.alwaysDo(MockMvcResultHandlers.print())
.build();
}
@Test
public void shouldReturnHalForms() throws Exception {
String jwt = JwtProvider.createJwtWithFixedExpirationDate("test sub", "1111", "test name");
Cookie cookie = new Cookie("accessJwt", jwt);
Cookie[] cookies = {cookie};
mvc.perform(get(create("/login/oauth2/code/facebook"))
.accept(MediaTypes.HAL_FORMS_JSON)
.cookie(cookies))
.andExpect(status().isOk());
} This test prints the links as arrays and not as key value pairs but doing a full spring boot test with the |
I'd really have to get an executable sample to be able to debug it to tell more. |
Your web controller methods need to be returning Spring HATEOAS types ( |
My DTO(response rather) extends |
Closing this due to the lack of feedback required to further diagnose this. |
Whenever I test my controller response with MockMvc, it does not return the correct response for links.
and not
The test is a slice test only testing a single controller. The test class is annotated with
@WebMvcTest(controller.class)
and@AutoConfigureMockMvc
.The text was updated successfully, but these errors were encountered: