Added ConverterFactory test
This commit is contained in:
parent
89f9f8c6bf
commit
753b309c3c
|
@ -1,6 +1,7 @@
|
||||||
package org.baeldung.controller;
|
package org.baeldung.controller;
|
||||||
|
|
||||||
import org.baeldung.domain.GenericEntity;
|
import org.baeldung.domain.GenericEntity;
|
||||||
|
import org.baeldung.domain.Modes;
|
||||||
import org.baeldung.web.resolver.Version;
|
import org.baeldung.web.resolver.Version;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -45,6 +46,11 @@ public class GenericEntityController {
|
||||||
return entityList.stream().findFirst().get();
|
return entityList.stream().findFirst().get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping("/entity/findbymode/{mode}")
|
||||||
|
public GenericEntity findByEnum(@PathVariable("mode") Modes mode) {
|
||||||
|
return entityList.stream().findFirst().get();
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping("/entity/findbyversion")
|
@RequestMapping("/entity/findbyversion")
|
||||||
public ResponseEntity findByVersion(@Version String version) {
|
public ResponseEntity findByVersion(@Version String version) {
|
||||||
return version != null
|
return version != null
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
package org.baeldung.domain;
|
||||||
|
|
||||||
|
public enum Modes {
|
||||||
|
|
||||||
|
Alpha, Beta;
|
||||||
|
}
|
|
@ -50,6 +50,16 @@ public class SpringBootApplicationIntegrationTest {
|
||||||
.andExpect(jsonPath("$.id", equalTo(1)));
|
.andExpect(jsonPath("$.id", equalTo(1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void givenRequestHasBeenMade_whenMeetsFindByModeOfGivenConditions_thenCorrect() throws Exception {
|
||||||
|
MediaType contentType = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
|
||||||
|
|
||||||
|
mockMvc.perform(MockMvcRequestBuilders.get("/entity/findbymode/{mode}", "Alpha"))
|
||||||
|
.andExpect(MockMvcResultMatchers.status().isOk())
|
||||||
|
.andExpect(MockMvcResultMatchers.content().contentType(contentType))
|
||||||
|
.andExpect(jsonPath("$.id", equalTo(1)));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void givenRequestHasBeenMade_whenMeetsFindByVersionOfGivenConditions_thenCorrect() throws Exception {
|
public void givenRequestHasBeenMade_whenMeetsFindByVersionOfGivenConditions_thenCorrect() throws Exception {
|
||||||
MediaType contentType = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
|
MediaType contentType = new MediaType(MediaType.APPLICATION_JSON.getType(), MediaType.APPLICATION_JSON.getSubtype(), Charset.forName("utf8"));
|
||||||
|
|
Loading…
Reference in New Issue