mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-05-12 17:04:48 +00:00
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:
parent
d2292f94a0
commit
ee6227c8b7
@ -34,6 +34,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@ -107,14 +108,14 @@ public abstract class AbstractTransformerController implements TransformControll
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
@GetMapping(value = "/info")
|
@GetMapping(value = "/transform/config")
|
||||||
public ResponseEntity<TransformConfig> info()
|
public ResponseEntity<TransformConfig> info()
|
||||||
{
|
{
|
||||||
logger.info("GET Transform Config.");
|
logger.info("GET Transform Config.");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ClassPathResource classPathResource = new ClassPathResource(ENGINE_CONFIG);
|
ClassPathResource classPathResource = new ClassPathResource(ENGINE_CONFIG);
|
||||||
File engineConfigFile = classPathResource.getFile();
|
InputStream engineConfigFile = classPathResource.getInputStream();
|
||||||
|
|
||||||
TransformConfig transformConfig = objectMapper.setSerializationInclusion(NON_NULL)
|
TransformConfig transformConfig = objectMapper.setSerializationInclusion(NON_NULL)
|
||||||
.readValue(engineConfigFile, TransformConfig.class);
|
.readValue(engineConfigFile, TransformConfig.class);
|
||||||
|
@ -312,7 +312,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
ReflectionTestUtils
|
ReflectionTestUtils
|
||||||
.setField(AbstractTransformerController.class, "ENGINE_CONFIG", "engine_config.json");
|
.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(
|
.andExpect(status().is(OK.value())).andExpect(
|
||||||
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
@ -330,7 +330,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
ReflectionTestUtils.setField(AbstractTransformerController.class, "ENGINE_CONFIG",
|
ReflectionTestUtils.setField(AbstractTransformerController.class, "ENGINE_CONFIG",
|
||||||
"engine_config_with_duplicates.json");
|
"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(
|
.andExpect(status().is(OK.value())).andExpect(
|
||||||
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
@ -357,7 +357,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
ReflectionTestUtils.setField(AbstractTransformerController.class, "ENGINE_CONFIG",
|
ReflectionTestUtils.setField(AbstractTransformerController.class, "ENGINE_CONFIG",
|
||||||
"engine_config_incomplete.json");
|
"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(
|
.andExpect(status().is(OK.value())).andExpect(
|
||||||
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
@ -379,7 +379,7 @@ public abstract class AbstractTransformerControllerTest
|
|||||||
ReflectionTestUtils.setField(AbstractTransformerController.class, "ENGINE_CONFIG",
|
ReflectionTestUtils.setField(AbstractTransformerController.class, "ENGINE_CONFIG",
|
||||||
"engine_config_no_transform_options.json");
|
"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(
|
.andExpect(status().is(OK.value())).andExpect(
|
||||||
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
header().string(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||||
.andReturn().getResponse().getContentAsString();
|
.andReturn().getResponse().getContentAsString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user