mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-09-17 14:21:18 +00:00
ATS-532 : Code improvements (#89)
- move startup message from controllers to the Application classes (SpringBoot configuration beans) - added static imports for most static variables and static methods - simplified a few nested *if*s - replaced Arrays.asList() with explicit immutable collections - fixed a few IntelliJ code inspection warnings
This commit is contained in:
@@ -66,13 +66,12 @@ import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilde
|
||||
@Import({SelectingTransformer.class})
|
||||
public class MiscControllerTest extends AbstractTransformerControllerTest
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private MiscController controller;
|
||||
|
||||
private String sourceEncoding = "UTF-8";
|
||||
private String targetEncoding = "UTF-8";
|
||||
private String targetMimetype = MIMETYPE_TEXT_PLAIN;
|
||||
private final String sourceEncoding = "UTF-8";
|
||||
private final String targetEncoding = "UTF-8";
|
||||
private final String targetMimetype = MIMETYPE_TEXT_PLAIN;
|
||||
|
||||
@Before
|
||||
public void before() throws Exception
|
||||
@@ -157,8 +156,8 @@ public class MiscControllerTest extends AbstractTransformerControllerTest
|
||||
@Test
|
||||
public void testStringToString() throws Exception
|
||||
{
|
||||
String expected = null;
|
||||
byte[] content = null;
|
||||
String expected;
|
||||
byte[] content;
|
||||
try
|
||||
{
|
||||
content = "azAz10!<21>$%^&*()\t\r\n".getBytes(UTF_8);
|
||||
@@ -204,14 +203,13 @@ public class MiscControllerTest extends AbstractTransformerControllerTest
|
||||
public void textToPdf() throws Exception
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String expected = null;
|
||||
for (int i = 1; i <= 5; i++)
|
||||
{
|
||||
sb.append(i);
|
||||
sb.append(" I must not talk in class or feed my homework to my cat.\n");
|
||||
}
|
||||
sb.append("\nBart\n");
|
||||
expected = sb.toString();
|
||||
String expected = sb.toString();
|
||||
|
||||
MvcResult result = sendText("txt",
|
||||
"UTF-8",
|
||||
@@ -301,13 +299,12 @@ public class MiscControllerTest extends AbstractTransformerControllerTest
|
||||
.param("sourceEncoding", sourceEncoding)
|
||||
.param("sourceMimetype", sourceMimetype);
|
||||
|
||||
MvcResult result = mockMvc
|
||||
return mockMvc
|
||||
.perform(requestBuilder)
|
||||
.andExpect(status().is(OK.value()))
|
||||
.andExpect(header().string("Content-Disposition",
|
||||
"attachment; filename*= " + targetEncoding + "''test_file." + targetExtension))
|
||||
.andReturn();
|
||||
return result;
|
||||
}
|
||||
|
||||
private String clean(String text)
|
||||
|
@@ -159,10 +159,8 @@ public class HtmlParserContentTransformerTest
|
||||
}
|
||||
}
|
||||
|
||||
private String readFromFile(File file, String encoding) throws Exception
|
||||
private String readFromFile(File file, final String encoding) throws Exception
|
||||
{
|
||||
String content = "wrong content";
|
||||
content = new String(Files.readAllBytes(file.toPath()), encoding);
|
||||
return content;
|
||||
return new String(Files.readAllBytes(file.toPath()), encoding);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user