7
Voglio scrivere test di base per eseguire una richiesta POST su un URL/utenti con payload JSON per creare un utente. Non riesco a trovare come convertire un nuovo oggetto JSON, e finora hanno così tanto, è ovviamente sbagliato, ma spiega lo scopo:Creare un oggetto JSON per postare nei test Spring Boot
@Test public void createUser() throws Exception {
String userJson = new User("My new User", "[email protected]").toJson();
this.mockMvc.perform(post("https://stackoverflow.com/users/").contentType(userJson)).andExpect(status().isCreated());
Proprio quello che cercavo: O) – chocksaway