aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-31 15:03:57 +0300
committerGravatar Vitaly Takmazov2018-10-31 15:03:57 +0300
commitd6385d656a0af52d9509f76dccce1172b663f2d9 (patch)
treeae9e24de7b71a80f7771a544163b7ea4c2e686ef
parentf119f0b85b9b96f724997eaf53b38594340a91c4 (diff)
Fix tests
-rw-r--r--juick-server/src/main/java/com/juick/server/CommandsManager.java4
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/ServerTests.java19
2 files changed, 16 insertions, 7 deletions
diff --git a/juick-server/src/main/java/com/juick/server/CommandsManager.java b/juick-server/src/main/java/com/juick/server/CommandsManager.java
index ade70dc9..a0904d33 100644
--- a/juick-server/src/main/java/com/juick/server/CommandsManager.java
+++ b/juick-server/src/main/java/com/juick/server/CommandsManager.java
@@ -516,12 +516,12 @@ public class CommandsManager {
attachmentType = attachmentFName.substring(attachmentFName.length() - 3);
}
int newrid = messagesService.createReply(mid, rid, user, txt, attachmentType);
- applicationEventPublisher.publishEvent(
- new MessageReadEvent(this, user, msg));
if (haveAttachment) {
String fname = String.format("%d-%d.%s", mid, newrid, attachmentType);
imagesService.saveImageWithPreviews(attachmentFName, fname);
}
+ applicationEventPublisher.publishEvent(
+ new MessageReadEvent(this, user, msg));
Message original = messagesService.getMessage(mid);
subscriptionService.subscribeMessage(original, user);
Message reply = messagesService.getReply(mid, newrid);
diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
index e9f42ee3..d3654e90 100644
--- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java
@@ -212,6 +212,10 @@ public class ServerTests {
@Before
public void setUp() throws Exception {
+ FileSystemUtils.deleteRecursively(Paths.get(imgDir, "p"));
+ FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-1024"));
+ FileSystemUtils.deleteRecursively(Paths.get(imgDir, "photos-512"));
+ FileSystemUtils.deleteRecursively(Paths.get(imgDir, "ps"));
Files.createDirectory(Paths.get(imgDir, "p"));
Files.createDirectory(Paths.get(imgDir, "photos-1024"));
Files.createDirectory(Paths.get(imgDir, "photos-512"));
@@ -1314,7 +1318,7 @@ public class ServerTests {
return null;
}
};
- assertThat(getStatus.get().getInbound().size(), is(0));
+ assertThat(getStatus.get().getInbound(), is(nullValue()));
ConnectionIn test = new ConnectionIn(server, new Socket("localhost", server.getServerPort()));
test.from.add(Jid.of("test"));
server.getInConnections().clear();
@@ -1634,6 +1638,9 @@ public class ServerTests {
}
@Test
public void notificationsTests() throws Exception {
+ jdbcTemplate.execute("DELETE FROM messages");
+ jdbcTemplate.execute("DELETE FROM replies");
+ jdbcTemplate.execute("DELETE FROM subscr_messages");
MvcResult loginResult = mockMvc.perform(post("/login")
.param("username", freefdName)
.param("password", freefdPassword))
@@ -1664,10 +1671,12 @@ public class ServerTests {
.andExpect(status().isOk())
.andReturn();
String outputDir = System.getProperty("io.springfox.staticdocs.outputDir");
- Files.createDirectories(Paths.get(outputDir));
- BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputDir, "swagger.json"), StandardCharsets.UTF_8);
- writer.write(result.getResponse().getContentAsString());
- writer.flush();
+ if (StringUtils.isNotEmpty(outputDir)) {
+ Files.createDirectories(Paths.get(outputDir));
+ BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputDir, "swagger.json"), StandardCharsets.UTF_8);
+ writer.write(result.getResponse().getContentAsString());
+ writer.flush();
+ }
}
@Test
public void newMessageShouldNotContainDuplicatedTags() throws Exception {