mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
ClientDataTests + tidy up
This commit is contained in:
@@ -120,10 +120,6 @@ public class TransformController
|
||||
if (transformEngines != null)
|
||||
{
|
||||
logSplitMessage(transformEngine.getStartupMessage());
|
||||
transformEngines.stream()
|
||||
.filter(te -> te != transformEngine)
|
||||
.sorted(Comparator.comparing(TransformEngine::getTransformEngineName))
|
||||
.forEach(te -> logSplitMessage(te.getStartupMessage()));
|
||||
}
|
||||
logger.info("--------------------------------------------------------------------------------------------------------------------------------------------------------------");
|
||||
logger.info("Starting application components... Done");
|
||||
|
@@ -195,9 +195,9 @@ abstract class ProcessHandler extends FragmentHandler
|
||||
if (transformerName == null)
|
||||
{
|
||||
throw new TransformException(BAD_REQUEST, "No transforms for: "+
|
||||
sourceMimetype+" -> "+targetMimetype+transformOptions.entrySet().stream()
|
||||
.map(entry -> entry.getKey()+"="+entry.getValue())
|
||||
.collect(Collectors.joining(", ", " ", "")));
|
||||
sourceMimetype+" -> "+targetMimetype+transformOptions.entrySet().stream()
|
||||
.map(entry -> entry.getKey()+"="+entry.getValue())
|
||||
.collect(Collectors.joining(", ", " ", "")));
|
||||
}
|
||||
return transformerName;
|
||||
}
|
||||
|
@@ -114,12 +114,6 @@ public class TransformControllerAllInOneTest
|
||||
+ "Startup AllInOne\n"
|
||||
+ "Line 2 AllInOne\n"
|
||||
+ "Line 3\n"
|
||||
+ "Startup OneCustomTransformer\n"
|
||||
+ "Line 2 OneCustomTransformer\n"
|
||||
+ "Line 3\n"
|
||||
+ "Startup TwoCustomTransformers\n"
|
||||
+ "Line 2 TwoCustomTransformers\n"
|
||||
+ "Line 3\n"
|
||||
+ "--------------------------------------------------------------------------------------------------------------------------------------------------------------\n"
|
||||
+ "Starting application components... Done",
|
||||
controllerLogMessages.toString());
|
||||
|
@@ -40,12 +40,10 @@ import org.alfresco.transform.base.fakes.FakeTransformerTxT2Pdf;
|
||||
import org.alfresco.transform.base.model.FileRefEntity;
|
||||
import org.alfresco.transform.base.model.FileRefResponse;
|
||||
import org.alfresco.transform.base.transform.TransformHandler;
|
||||
import org.alfresco.transform.base.transform.FragmentTest;
|
||||
import org.alfresco.transform.client.model.TransformReply;
|
||||
import org.alfresco.transform.client.model.TransformRequest;
|
||||
import org.alfresco.transform.config.TransformConfig;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
import org.mockito.stubbing.Answer;
|
||||
@@ -130,25 +128,6 @@ public class TransformControllerTest
|
||||
@MockBean
|
||||
protected AlfrescoSharedFileStoreClient fakeSfsClient;
|
||||
|
||||
private void fakeSfsClient()
|
||||
{
|
||||
final Map<String,File> sfsRef2File = new HashMap<>();
|
||||
when(fakeSfsClient.saveFile(any())).thenAnswer((Answer) invocation -> {
|
||||
File originalFile = (File) invocation.getArguments()[0];
|
||||
|
||||
// Make a copy as the original might get deleted
|
||||
File fileCopy = new File(tempDir, originalFile.getName()+"copy");
|
||||
FileUtils.copyFile(originalFile, fileCopy);
|
||||
|
||||
String fileRef = UUID.randomUUID().toString();
|
||||
sfsRef2File.put(fileRef, fileCopy);
|
||||
return new FileRefResponse(new FileRefEntity(fileRef));
|
||||
});
|
||||
when(fakeSfsClient.retrieveFile(any())).thenAnswer((Answer) invocation ->
|
||||
ResponseEntity.ok().header(CONTENT_DISPOSITION,"attachment; filename*=UTF-8''transform.tmp")
|
||||
.body((Resource) new UrlResource(sfsRef2File.get(invocation.getArguments()[0]).toURI())));
|
||||
}
|
||||
|
||||
static void resetProbeForTesting(TransformController transformController)
|
||||
{
|
||||
transformController.transformHandler.getProbeTransform().resetForTesting();
|
||||
@@ -178,7 +157,7 @@ public class TransformControllerTest
|
||||
controllerLogMessages.toString());
|
||||
}
|
||||
|
||||
static StringJoiner getLogMessagesFor(Class classBeingLogged)
|
||||
public static StringJoiner getLogMessagesFor(Class classBeingLogged)
|
||||
{
|
||||
StringJoiner logMessages = new StringJoiner("\n");
|
||||
Logger logger = (Logger) LoggerFactory.getLogger(classBeingLogged);
|
||||
@@ -302,7 +281,23 @@ public class TransformControllerTest
|
||||
@Test
|
||||
public void testTransformEndpointThatUsesTransformRequests() throws Exception
|
||||
{
|
||||
fakeSfsClient();
|
||||
final Map<String,File> sfsRef2File = new HashMap<>();
|
||||
when(fakeSfsClient.saveFile(any())).thenAnswer((Answer) invocation -> {
|
||||
File originalFile = (File) invocation.getArguments()[0];
|
||||
|
||||
// Make a copy as the original might get deleted
|
||||
File fileCopy = new File(tempDir, originalFile.getName()+"copy");
|
||||
FileUtils.copyFile(originalFile, fileCopy);
|
||||
|
||||
String fileRef = UUID.randomUUID().toString();
|
||||
sfsRef2File.put(fileRef, fileCopy);
|
||||
return new FileRefResponse(new FileRefEntity(fileRef));
|
||||
});
|
||||
|
||||
when(fakeSfsClient.retrieveFile(any())).thenAnswer((Answer) invocation ->
|
||||
ResponseEntity.ok().header(CONTENT_DISPOSITION,"attachment; filename*=UTF-8''transform.tmp")
|
||||
.body((Resource) new UrlResource(sfsRef2File.get(invocation.getArguments()[0]).toURI())));
|
||||
|
||||
File sourceFile = getTestFile("original.txt", true, tempDir);
|
||||
String sourceFileRef = fakeSfsClient.saveFile(sourceFile).getEntry().getFileRef();
|
||||
|
||||
|
@@ -68,7 +68,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
@@ -79,7 +78,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
||||
@ContextConfiguration(classes = {
|
||||
FakeTransformEngineWithFragments.class,
|
||||
FakeTransformerFragments.class})
|
||||
public class FragmentTest
|
||||
public class FragmentHandlerTest
|
||||
{
|
||||
@Autowired
|
||||
private TransformHandler transformHandler;
|
Reference in New Issue
Block a user