ACS-2498 Add coreVersion to T-Engine config (#526)

The bulk of the changes in this PR are to do with adding a coreVersion element to the transform element in the T-Engine config. For more detail see the class header of CoreVersionDecorator.

* Support the use of coreVersion so that it is possible to upgrade pods in any order
* Moved the majority of the RequestParamMap static finals to alfresco-transform-model and added a new one: "includeCoreVersion" parameter.
This commit is contained in:
Alan Davis 2022-02-09 22:39:40 +00:00 committed by GitHub
parent e575ec943a
commit df519cfd6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 128 additions and 62 deletions

View File

@ -5,7 +5,7 @@ PS4="\[\e[35m\]+ \[\e[m\]"
set +e -v -x set +e -v -x
pushd "$(dirname "${BASH_SOURCE[0]}")/../" pushd "$(dirname "${BASH_SOURCE[0]}")/../"
mvn -B -q clean install \ mvn -B -U -q clean install \
-DskipTests \ -DskipTests \
-Dmaven.javadoc.skip=true \ -Dmaven.javadoc.skip=true \
com.srcclr:srcclr-maven-plugin:scan \ com.srcclr:srcclr-maven-plugin:scan \

View File

@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@ -35,6 +35,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import java.io.File; import java.io.File;
import java.util.HashMap; import java.util.HashMap;
@ -42,6 +43,8 @@ import java.util.Map;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_HTML; import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_HTML;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN; import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
import static org.alfresco.transform.client.model.config.CoreVersionDecorator.setOrClearCoreVersion;
import static org.alfresco.transformer.util.RequestParamMap.INCLUDE_CORE_VERSION;
import static org.alfresco.transformer.util.RequestParamMap.SOURCE_ENCODING; import static org.alfresco.transformer.util.RequestParamMap.SOURCE_ENCODING;
import static org.alfresco.transformer.util.RequestParamMap.TRANSFORM_NAME_PARAMETER; import static org.alfresco.transformer.util.RequestParamMap.TRANSFORM_NAME_PARAMETER;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
@ -88,10 +91,12 @@ public class AIOController extends AbstractTransformerController
} }
@Override @Override
public ResponseEntity<TransformConfig> info() public ResponseEntity<TransformConfig> info(
@RequestParam(value = INCLUDE_CORE_VERSION, required = false) Boolean includeCoreVersion)
{ {
logger.info("GET Transform Config."); logger.info("GET Transform Config" + (includeCoreVersion != null && includeCoreVersion ? " including coreVersion" : ""));
TransformConfig transformConfig = transformRegistry.getTransformConfig(); TransformConfig transformConfig = transformRegistry.getTransformConfig();
transformConfig = setOrClearCoreVersion(transformConfig, includeCoreVersion);
return new ResponseEntity<>(transformConfig, OK); return new ResponseEntity<>(transformConfig, OK);
} }
@ -105,7 +110,7 @@ public class AIOController extends AbstractTransformerController
Transformer transformer = transformRegistry.getByTransformName(transformName); Transformer transformer = transformRegistry.getByTransformName(transformName);
if (transformer == null) if (transformer == null)
{ {
new TransformException(INTERNAL_SERVER_ERROR.value(), "No transformer mapping for - transform:" throw new TransformException(INTERNAL_SERVER_ERROR.value(), "No transformer mapping for - transform:"
+ transformName + " sourceMimetype:" + sourceMimetype + " targetMimetype:" + targetMimetype); + transformName + " sourceMimetype:" + sourceMimetype + " targetMimetype:" + targetMimetype);
} }

View File

@ -2,6 +2,7 @@ queue:
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.aio.acs} engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.aio.acs}
transform: transform:
core: core:
version: @project.version@
pdfrenderer: pdfrenderer:
exe: ${PDFRENDERER_EXE:/usr/bin/alfresco-pdf-renderer} exe: ${PDFRENDERER_EXE:/usr/bin/alfresco-pdf-renderer}
libreoffice: libreoffice:

View File

@ -106,6 +106,14 @@ public class AIOControllerImageMagickTest extends ImageMagickControllerTest
} }
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test @Test
@Override @Override
public void testGetInfoFromConfigWithDuplicates() public void testGetInfoFromConfigWithDuplicates()

View File

@ -88,6 +88,13 @@ public class AIOControllerLibreOfficeTest extends LibreOfficeControllerTest
} }
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test @Test
@Override @Override
public void testGetInfoFromConfigWithDuplicates() public void testGetInfoFromConfigWithDuplicates()

View File

@ -50,10 +50,17 @@ public class AIOControllerMiscTest extends MiscControllerTest
@Override @Override
public void testGetTransformConfigInfo() public void testGetTransformConfigInfo()
{ {
// Ignore the test in super class as the way the AIO transformer provides config is fundamentality different. // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
} }
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test @Test
@Override @Override
public void testGetInfoFromConfigWithDuplicates() public void testGetInfoFromConfigWithDuplicates()

View File

@ -84,9 +84,15 @@ public class AIOControllerPdfRendererTest extends AlfrescoPdfRendererControllerT
public void testGetTransformConfigInfo() public void testGetTransformConfigInfo()
{ {
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different. // Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
} }
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test @Test
@Override @Override
public void testGetInfoFromConfigWithDuplicates() public void testGetInfoFromConfigWithDuplicates()

View File

@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@ -38,7 +38,6 @@ import org.springframework.context.annotation.Import;
@Import(AIOCustomConfig.class) @Import(AIOCustomConfig.class)
public class AIOControllerTest //extends AbstractTransformerControllerTest public class AIOControllerTest //extends AbstractTransformerControllerTest
{ {
@Autowired @Autowired
AIOController aioController; AIOController aioController;
@ -64,6 +63,12 @@ public class AIOControllerTest //extends AbstractTransformerControllerTest
@Test @Test
public void emptyTest() public void emptyTest()
{ {
aioController.info(); aioController.info(null);
}
@Test
public void emptyTestWithIncludeCoreVersion()
{
aioController.info(true);
} }
} }

View File

@ -57,6 +57,14 @@ public class AIOControllerTikaTest extends TikaControllerTest
} }
@Test
@Override
public void testGetTransformConfigInfoExcludingCoreVersion()
{
// Ignore the test in super class as the way the AIO transformer provides config is fundamentally different.
}
@Test @Test
@Override @Override
public void testGetInfoFromConfigWithDuplicates() public void testGetInfoFromConfigWithDuplicates()

View File

@ -2,6 +2,7 @@ queue:
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.imagemagick.acs} engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.imagemagick.acs}
transform: transform:
core: core:
version: @project.version@
config: config:
location: classpath:imagemagick_engine_config.json location: classpath:imagemagick_engine_config.json
imagemagick: imagemagick:

View File

@ -2,6 +2,7 @@ queue:
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.libreoffice.acs} engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.libreoffice.acs}
transform: transform:
core: core:
version: @project.version@
config: config:
location: classpath:libreoffice_engine_config.json location: classpath:libreoffice_engine_config.json
libreoffice: libreoffice:

View File

@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@ -38,7 +38,7 @@ import java.util.Map;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_HTML; import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_HTML;
import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN; import static org.alfresco.transform.client.model.Mimetype.MIMETYPE_TEXT_PLAIN;
import static org.alfresco.transformer.transformers.HtmlParserContentTransformer.SOURCE_ENCODING; import static org.alfresco.transformer.util.RequestParamMap.SOURCE_ENCODING;
import static org.alfresco.transformer.util.RequestParamMap.TRANSFORM_NAME_PARAMETER; import static org.alfresco.transformer.util.RequestParamMap.TRANSFORM_NAME_PARAMETER;
@Controller @Controller

View File

@ -2,5 +2,6 @@ queue:
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.misc.acs} engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.misc.acs}
transform: transform:
core: core:
version: @project.version@
config: config:
location: classpath:misc_engine_config.json location: classpath:misc_engine_config.json

View File

@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@ -42,6 +42,8 @@ import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.IllegalCharsetNameException;
import java.util.Map; import java.util.Map;
import static org.alfresco.transform.client.util.RequestParamMap.SOURCE_ENCODING;
/** /**
* Content transformer which wraps the HTML Parser library for * Content transformer which wraps the HTML Parser library for
* parsing HTML content. * parsing HTML content.

View File

@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@ -36,9 +36,6 @@ import java.util.Map;
*/ */
public interface SelectableTransformer public interface SelectableTransformer
{ {
String SOURCE_ENCODING = "sourceEncoding";
String TARGET_ENCODING = "targetEncoding";
default void transform(String sourceMimetype, String targetMimetype, Map<String, String> parameters, default void transform(String sourceMimetype, String targetMimetype, Map<String, String> parameters,
File sourceFile, File targetFile) throws Exception File sourceFile, File targetFile) throws Exception
{ {

View File

@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@ -42,6 +42,9 @@ import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.IllegalCharsetNameException;
import java.util.Map; import java.util.Map;
import static org.alfresco.transform.client.util.RequestParamMap.SOURCE_ENCODING;
import static org.alfresco.transform.client.util.RequestParamMap.TARGET_ENCODING;
/** /**
* Converts any textual format to plain text. * Converts any textual format to plain text.
* <p> * <p>

View File

@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@ -50,6 +50,8 @@ import java.nio.charset.Charset;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static org.alfresco.transform.client.util.RequestParamMap.SOURCE_ENCODING;
/** /**
* <p> * <p>
* This code is based on a class of the same name originally implemented in alfresco-repository. * This code is based on a class of the same name originally implemented in alfresco-repository.

View File

@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@ -35,7 +35,7 @@ import java.nio.file.Files;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static org.alfresco.transformer.transformers.StringExtractingContentTransformer.SOURCE_ENCODING; import static org.alfresco.transform.client.util.RequestParamMap.SOURCE_ENCODING;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
public class HtmlParserContentTransformerTest public class HtmlParserContentTransformerTest

View File

@ -2,6 +2,7 @@ queue:
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.alfresco-pdf-renderer.acs} engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.alfresco-pdf-renderer.acs}
transform: transform:
core: core:
version: @project.version@
config: config:
location: classpath:pdfrenderer_engine_config.json location: classpath:pdfrenderer_engine_config.json
pdfrenderer: pdfrenderer:

View File

@ -2,6 +2,7 @@ queue:
engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.tika.acs} engineRequestQueue: ${TRANSFORM_ENGINE_REQUEST_QUEUE:org.alfresco.transform.engine.tika.acs}
transform: transform:
core: core:
version: @project.version@
config: config:
location: classpath:tika_engine_config.json location: classpath:tika_engine_config.json
tika: tika:

View File

@ -63,6 +63,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.joining;
import static org.alfresco.transform.client.model.config.CoreVersionDecorator.setOrClearCoreVersion;
import static org.alfresco.transform.client.util.RequestParamMap.INCLUDE_CORE_VERSION;
import static org.alfresco.transformer.fs.FileManager.TempFileProvider.createTempFile; import static org.alfresco.transformer.fs.FileManager.TempFileProvider.createTempFile;
import static org.alfresco.transformer.fs.FileManager.buildFile; import static org.alfresco.transformer.fs.FileManager.buildFile;
import static org.alfresco.transformer.fs.FileManager.createAttachment; import static org.alfresco.transformer.fs.FileManager.createAttachment;
@ -140,11 +142,12 @@ public abstract class AbstractTransformerController implements TransformControll
private TransformerDebug transformerDebug; private TransformerDebug transformerDebug;
@GetMapping(value = "/transform/config") @GetMapping(value = "/transform/config")
public ResponseEntity<TransformConfig> info() public ResponseEntity<TransformConfig> info(
@RequestParam(value = INCLUDE_CORE_VERSION, required = false) Boolean includeCoreVersion)
{ {
logger.info("GET Transform Config."); logger.info("GET Transform Config" + (includeCoreVersion != null && includeCoreVersion ? " including coreVersion" : ""));
final TransformConfig transformConfig = TransformConfig transformConfig = ((TransformRegistryImpl) transformRegistry).getTransformConfig();
((TransformRegistryImpl) transformRegistry).getTransformConfig(); transformConfig = setOrClearCoreVersion(transformConfig, includeCoreVersion);
return new ResponseEntity<>(transformConfig, OK); return new ResponseEntity<>(transformConfig, OK);
} }

View File

@ -26,6 +26,7 @@
package org.alfresco.transformer; package org.alfresco.transformer;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import static org.alfresco.transform.client.model.config.CoreVersionDecorator.setCoreVersionOnSingleStepTransformers;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import java.io.IOException; import java.io.IOException;
@ -61,6 +62,9 @@ public class TransformRegistryImpl extends AbstractTransformRegistry
@Value("${transform.core.config.location:classpath:engine_config.json}") @Value("${transform.core.config.location:classpath:engine_config.json}")
private String locationFromProperty; private String locationFromProperty;
@Value("${transform.core.version}")
private String coreVersion;
private Resource engineConfig; private Resource engineConfig;
@PostConstruct @PostConstruct
@ -82,7 +86,9 @@ public class TransformRegistryImpl extends AbstractTransformRegistry
{ {
try (Reader reader = new InputStreamReader(engineConfig.getInputStream(), UTF_8)) try (Reader reader = new InputStreamReader(engineConfig.getInputStream(), UTF_8))
{ {
return jsonObjectMapper.readValue(reader, TransformConfig.class); TransformConfig transformConfig = jsonObjectMapper.readValue(reader, TransformConfig.class);
setCoreVersionOnSingleStepTransformers(transformConfig.getTransformers(), coreVersion);
return transformConfig;
} }
catch (IOException e) catch (IOException e)
{ {

View File

@ -2,7 +2,7 @@
* #%L * #%L
* Alfresco Transform Core * Alfresco Transform Core
* %% * %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited * Copyright (C) 2005 - 2022 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* - * -
@ -26,7 +26,11 @@
*/ */
package org.alfresco.transformer.util; package org.alfresco.transformer.util;
public interface RequestParamMap /**
* Extends the list of transform options with historic request parameters or 'extra' parameters used in testing
* or communication in the all-in-one transformer.
*/
public interface RequestParamMap extends org.alfresco.transform.client.util.RequestParamMap
{ {
// This property can be sent by acs repository's legacy transformers to force a transform, // This property can be sent by acs repository's legacy transformers to force a transform,
// instead of letting this T-Engine determine it based on the request parameters. // instead of letting this T-Engine determine it based on the request parameters.
@ -35,41 +39,12 @@ public interface RequestParamMap
// See ATS-731. // See ATS-731.
@Deprecated @Deprecated
String TRANSFORM_NAME_PROPERTY = "transformName"; String TRANSFORM_NAME_PROPERTY = "transformName";
String TRANSFORM_NAME_PARAMETER = "alfresco.transform-name-parameter"; String TRANSFORM_NAME_PARAMETER = "alfresco.transform-name-parameter";
String FILE = "file";
String SOURCE_ENCODING = "sourceEncoding"; String FILE = "file";
String SOURCE_EXTENSION = "sourceExtension"; String SOURCE_EXTENSION = "sourceExtension";
String SOURCE_MIMETYPE = "sourceMimetype"; String SOURCE_MIMETYPE = "sourceMimetype";
String TARGET_EXTENSION = "targetExtension"; String TARGET_EXTENSION = "targetExtension";
String TARGET_MIMETYPE = "targetMimetype"; String TARGET_MIMETYPE = "targetMimetype";
String TARGET_ENCODING = "targetEncoding";
String TEST_DELAY = "testDelay"; String TEST_DELAY = "testDelay";
String PAGE_REQUEST_PARAM = "page";
String WIDTH_REQUEST_PARAM = "width";
String HEIGHT_REQUEST_PARAM = "height";
String ALLOW_PDF_ENLARGEMENT = "allowPdfEnlargement";
String MAINTAIN_PDF_ASPECT_RATIO = "maintainPdfAspectRatio";
String START_PAGE = "startPage";
String END_PAGE = "endPage";
String ALPHA_REMOVE = "alphaRemove";
String AUTO_ORIENT = "autoOrient";
String CROP_GRAVITY = "cropGravity";
String CROP_WIDTH = "cropWidth";
String CROP_HEIGHT = "cropHeight";
String CROP_PERCENTAGE = "cropPercentage";
String CROP_X_OFFSET = "cropXOffset";
String CROP_Y_OFFSET = "cropYOffset";
String THUMBNAIL = "thumbnail";
String RESIZE_WIDTH = "resizeWidth";
String RESIZE_HEIGHT = "resizeHeight";
String RESIZE_PERCENTAGE = "resizePercentage";
String ALLOW_ENLARGEMENT = "allowEnlargement";
String MAINTAIN_ASPECT_RATIO = "maintainAspectRatio";
String COMMAND_OPTIONS = "commandOptions";
String TIMEOUT = "timeout";
String INCLUDE_CONTENTS = "includeContents";
String NOT_EXTRACT_BOOKMARKS_TEXT = "notExtractBookmarksText";
String PAGE_LIMIT = "pageLimit";
} }

View File

@ -69,6 +69,7 @@ import org.alfresco.transformer.probes.ProbeTestTransform;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.api.io.TempDir;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.boot.test.mock.mockito.SpyBean; import org.springframework.boot.test.mock.mockito.SpyBean;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
@ -103,6 +104,9 @@ public abstract class AbstractTransformerControllerTest
@SpyBean @SpyBean
protected TransformServiceRegistry transformRegistry; protected TransformServiceRegistry transformRegistry;
@Value("${transform.core.version}")
private String currentCoreVersion;
protected String sourceExtension; protected String sourceExtension;
protected String targetExtension; protected String targetExtension;
protected String sourceMimetype; protected String sourceMimetype;
@ -407,6 +411,28 @@ public abstract class AbstractTransformerControllerTest
@Test @Test
public void testGetTransformConfigInfo() throws Exception public void testGetTransformConfigInfo() throws Exception
{
TransformConfig expectedTransformConfig = objectMapper
.readValue(getTestFile(getEngineConfigName(), true),
TransformConfig.class);
expectedTransformConfig.getTransformers().forEach(transformer -> transformer.setCoreVersion(currentCoreVersion));
ReflectionTestUtils.setField(transformRegistry, "engineConfig",
new ClassPathResource(getEngineConfigName()));
String response = mockMvc
.perform(MockMvcRequestBuilders.get("/transform/config?includeCoreVersion=true"))
.andExpect(status().is(OK.value()))
.andExpect(header().string(CONTENT_TYPE, APPLICATION_JSON_VALUE))
.andReturn().getResponse().getContentAsString();
TransformConfig transformConfig = objectMapper.readValue(response, TransformConfig.class);
assertEquals(expectedTransformConfig, transformConfig);
}
@Test
// Test for case when T-Router or Repository is a version that does not expect it
public void testGetTransformConfigInfoExcludingCoreVersion() throws Exception
{ {
TransformConfig expectedTransformConfig = objectMapper TransformConfig expectedTransformConfig = objectMapper
.readValue(getTestFile(getEngineConfigName(), true), .readValue(getTestFile(getEngineConfigName(), true),

View File

@ -21,7 +21,7 @@
<dependency.pdfbox.version>2.0.25</dependency.pdfbox.version> <dependency.pdfbox.version>2.0.25</dependency.pdfbox.version>
<dependency.alfresco-jodconverter-core.version>3.0.1.12</dependency.alfresco-jodconverter-core.version> <dependency.alfresco-jodconverter-core.version>3.0.1.12</dependency.alfresco-jodconverter-core.version>
<env.project_version>${project.version}</env.project_version> <env.project_version>${project.version}</env.project_version>
<dependency.alfresco-transform-model.version>1.4.8</dependency.alfresco-transform-model.version> <dependency.alfresco-transform-model.version>1.4.9</dependency.alfresco-transform-model.version>
<dependency.activemq.version>5.16.3</dependency.activemq.version> <dependency.activemq.version>5.16.3</dependency.activemq.version>
<dependency.jackson.version>2.13.1</dependency.jackson.version> <dependency.jackson.version>2.13.1</dependency.jackson.version>
<dependency.jackson-databind.version>${dependency.jackson.version}</dependency.jackson-databind.version> <dependency.jackson-databind.version>${dependency.jackson.version}</dependency.jackson-databind.version>