ATS-434 : Implement /transform/config endpoint in T-Engines (#46)

- fix config file loading
- rename `/info` endpoint to '/transform/config'
This commit is contained in:
DenisGabriela 2019-06-04 13:43:58 +03:00 committed by CezarLeahu
parent d2292f94a0
commit ee6227c8b7
2 changed files with 7 additions and 6 deletions

View File

@ -34,6 +34,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Collectors;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -107,14 +108,14 @@ public abstract class AbstractTransformerController implements TransformControll
@Autowired
private ObjectMapper objectMapper;
@GetMapping(value = "/info")
@GetMapping(value = "/transform/config")
public ResponseEntity<TransformConfig> info()
{
logger.info("GET Transform Config.");
try
{
ClassPathResource classPathResource = new ClassPathResource(ENGINE_CONFIG);
File engineConfigFile = classPathResource.getFile();
InputStream engineConfigFile = classPathResource.getInputStream();
TransformConfig transformConfig = objectMapper.setSerializationInclusion(NON_NULL)
.readValue(engineConfigFile, TransformConfig.class);

View File

@ -312,7 +312,7 @@ public abstract class AbstractTransformerControllerTest
ReflectionTestUtils
.setField(AbstractTransformerController.class, "ENGINE_CONFIG", "engine_config.json");
String response = mockMvc.perform(MockMvcRequestBuilders.get("/info"))
String response = mockMvc.perform(MockMvcRequestBuilders.get("/transform/config"))
.andExpect(status().is(OK.value())).andExpect(
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
.andReturn().getResponse().getContentAsString();
@ -330,7 +330,7 @@ public abstract class AbstractTransformerControllerTest
ReflectionTestUtils.setField(AbstractTransformerController.class, "ENGINE_CONFIG",
"engine_config_with_duplicates.json");
String response = mockMvc.perform(MockMvcRequestBuilders.get("/info"))
String response = mockMvc.perform(MockMvcRequestBuilders.get("/transform/config"))
.andExpect(status().is(OK.value())).andExpect(
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
.andReturn().getResponse().getContentAsString();
@ -357,7 +357,7 @@ public abstract class AbstractTransformerControllerTest
ReflectionTestUtils.setField(AbstractTransformerController.class, "ENGINE_CONFIG",
"engine_config_incomplete.json");
String response = mockMvc.perform(MockMvcRequestBuilders.get("/info"))
String response = mockMvc.perform(MockMvcRequestBuilders.get("/transform/config"))
.andExpect(status().is(OK.value())).andExpect(
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
.andReturn().getResponse().getContentAsString();
@ -379,7 +379,7 @@ public abstract class AbstractTransformerControllerTest
ReflectionTestUtils.setField(AbstractTransformerController.class, "ENGINE_CONFIG",
"engine_config_no_transform_options.json");
String response = mockMvc.perform(MockMvcRequestBuilders.get("/info"))
String response = mockMvc.perform(MockMvcRequestBuilders.get("/transform/config"))
.andExpect(status().is(OK.value())).andExpect(
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
.andReturn().getResponse().getContentAsString();