mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-07-31 17:38:33 +00:00
ATS-175 : Replace HTTP numeric codes with constants
This commit is contained in:
@@ -18,6 +18,8 @@ import static org.alfresco.transformer.fs.FileManager.createTargetFileName;
|
||||
import static org.alfresco.transformer.logging.StandardMessages.ENTERPRISE_LICENCE;
|
||||
import static org.alfresco.transformer.util.Util.stringToBoolean;
|
||||
import static org.alfresco.transformer.util.Util.stringToInteger;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
@@ -166,7 +168,7 @@ public class ImageMagickController extends AbstractTransformerController
|
||||
|
||||
final ResponseEntity<Resource> body = createAttachment(targetFilename, targetFile);
|
||||
LogEntry.setTargetSize(targetFile.length());
|
||||
long time = LogEntry.setStatusCodeAndMessage(200, "Success");
|
||||
long time = LogEntry.setStatusCodeAndMessage(OK.value(), "Success");
|
||||
time += LogEntry.addDelay(testDelay);
|
||||
getProbeTestTransform().recordTransformTime(time);
|
||||
return body;
|
||||
@@ -217,7 +219,7 @@ public class ImageMagickController extends AbstractTransformerController
|
||||
}
|
||||
else if (!GRAVITY_VALUES.contains(cropGravity))
|
||||
{
|
||||
throw new TransformException(400, "Invalid cropGravity value");
|
||||
throw new TransformException(BAD_REQUEST.value(), "Invalid cropGravity value");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,6 +32,8 @@ import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.springframework.http.HttpStatus.BAD_REQUEST;
|
||||
import static org.springframework.http.HttpStatus.OK;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
|
||||
@@ -186,7 +188,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
||||
.file(sourceFile)
|
||||
.param("targetExtension", targetExtension)
|
||||
.param("cropGravity", value))
|
||||
.andExpect(status().is(200))
|
||||
.andExpect(status().is(OK.value()))
|
||||
.andExpect(content().bytes(expectedTargetFileBytes))
|
||||
.andExpect(header().string("Content-Disposition", "attachment; filename*= UTF-8''quick."+targetExtension));
|
||||
}
|
||||
@@ -199,7 +201,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
||||
.file(sourceFile)
|
||||
.param("targetExtension", targetExtension)
|
||||
.param("cropGravity", "badValue"))
|
||||
.andExpect(status().is(400));
|
||||
.andExpect(status().is(BAD_REQUEST.value()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -231,7 +233,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
||||
.param("allowEnlargement", "true")
|
||||
.param("maintainAspectRatio", "true"))
|
||||
|
||||
.andExpect(status().is(200))
|
||||
.andExpect(status().is(OK.value()))
|
||||
.andExpect(content().bytes(expectedTargetFileBytes))
|
||||
.andExpect(header().string("Content-Disposition", "attachment; filename*= UTF-8''quick."+targetExtension));
|
||||
}
|
||||
@@ -265,7 +267,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
||||
.param("allowEnlargement", "false")
|
||||
.param("maintainAspectRatio", "false"))
|
||||
|
||||
.andExpect(status().is(200))
|
||||
.andExpect(status().is(OK.value()))
|
||||
.andExpect(content().bytes(expectedTargetFileBytes))
|
||||
.andExpect(header().string("Content-Disposition", "attachment; filename*= UTF-8''quick."+targetExtension));
|
||||
}
|
||||
@@ -282,7 +284,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
||||
.param("resizeWidth", "321")
|
||||
.param("resizeHeight", "654")
|
||||
.param("commandOptions", "( horrible command / );"))
|
||||
.andExpect(status().is(200))
|
||||
.andExpect(status().is(OK.value()))
|
||||
.andExpect(content().bytes(expectedTargetFileBytes))
|
||||
.andExpect(header().string("Content-Disposition", "attachment; filename*= UTF-8''quick."+targetExtension));
|
||||
}
|
||||
@@ -302,7 +304,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
||||
when(mockExecutionResult.getExitValue()).thenReturn(1);
|
||||
|
||||
mockMvc.perform(mockMvcRequest("/transform", sourceFile, "targetExtension", "xxx"))
|
||||
.andExpect(status().is(400))
|
||||
.andExpect(status().is(BAD_REQUEST.value()))
|
||||
.andExpect(status().reason(containsString("Transformer exit code was not 0: \nSTDERR")));
|
||||
}
|
||||
|
||||
@@ -330,7 +332,7 @@ public class ImageMagickControllerTest extends AbstractTransformerControllerTest
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=quick." + sourceExtension);
|
||||
ResponseEntity<Resource> response = new ResponseEntity<>(new FileSystemResource(
|
||||
sourceFile), headers, HttpStatus.OK);
|
||||
sourceFile), headers, OK);
|
||||
|
||||
when(alfrescoSharedFileStoreClient.retrieveFile(sourceFileRef)).thenReturn(response);
|
||||
when(alfrescoSharedFileStoreClient.saveFile(any())).thenReturn(new FileRefResponse(new FileRefEntity(targetFileRef)));
|
||||
|
Reference in New Issue
Block a user