aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-01-15 14:49:51 +0300
committerGravatar Vitaly Takmazov2016-01-15 14:49:51 +0300
commitf9d5099bf4be816aa267e02b5713a672fd4da562 (patch)
treea3cd6f2015fb823ad4a25035f8dfe36c1deede23
parent552bc5210ecc06e58dcf4d67fb6191dbac2a219c (diff)
spring-jdbc WIP
m---------deps/com.juick.server10
-rw-r--r--src/main/java/com/juick/api/Messages.java12
-rw-r--r--src/test/java/com/juick/tests/ApiTests.java9
3 files changed, 20 insertions, 11 deletions
diff --git a/deps/com.juick.server b/deps/com.juick.server
-Subproject 1ef890d21db2ed9aeefc37b71ff82d0f59df851
+Subproject 2635d6187ecd48c732d21e4f510f1df8451ce64
diff --git a/src/main/java/com/juick/api/Messages.java b/src/main/java/com/juick/api/Messages.java
index e3dcabfd..fb9be051 100644
--- a/src/main/java/com/juick/api/Messages.java
+++ b/src/main/java/com/juick/api/Messages.java
@@ -82,7 +82,7 @@ public class Messages {
}
public void doGetRecommended(HttpServletRequest request, HttpServletResponse response, int vuid) throws ServletException, IOException {
- /*int before_mid = Utils.parseInt(request.getParameter("before_mid"), 0);
+ int before_mid = Utils.parseInt(request.getParameter("before_mid"), 0);
List<Integer> mids = MessagesQueries.getUserRecommendations(sql, vuid, before_mid);
if (mids != null && !mids.isEmpty()) {
@@ -95,21 +95,21 @@ public class Messages {
}
} else {
response.sendError(404);
- }*/
+ }
}
public void doSetPrivacy(HttpServletRequest request, HttpServletResponse response, Stream xmpp, int vuid) throws ServletException, IOException {
- /*int mid = Utils.parseInt(request.getParameter("mid"), 0);
+ int mid = Utils.parseInt(request.getParameter("mid"), 0);
com.juick.User user = MessagesQueries.getMessageAuthor(sql, mid);
if (user != null && user.UID == vuid && MessagesQueries.setMessagePrivacy(sql, mid)) {
Main.replyJSON(request, response, "{\"status\":\"ok\"}");
} else {
response.sendError(400);
- }*/
+ }
}
public void doSetPopular(HttpServletRequest request, HttpServletResponse response, Stream xmpp) throws ServletException, IOException {
- /*int mid = Utils.parseInt(request.getParameter("mid"), 0);
+ int mid = Utils.parseInt(request.getParameter("mid"), 0);
int popular = Utils.parseInt(request.getParameter("popular"), 0);
if (mid > 0) {
@@ -141,6 +141,6 @@ public class Messages {
}
Main.replyJSON(request, response, "{\"status\":\"ok\"}");
- }*/
+ }
}
}
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java
index f111ffc7..e67c23f2 100644
--- a/src/test/java/com/juick/tests/ApiTests.java
+++ b/src/test/java/com/juick/tests/ApiTests.java
@@ -1,7 +1,9 @@
package com.juick.tests;
+import com.juick.Message;
import com.juick.User;
import com.juick.server.UserQueries;
+import com.juick.server.MessagesQueries;
import junit.framework.Assert;
import org.apache.commons.dbcp2.BasicDataSource;
import org.junit.Before;
@@ -38,4 +40,11 @@ public class ApiTests {
User user = UserQueries.getUserByUID(jdbc, 3694);
Assert.assertEquals("it should be me", "vt", user.UName);
}
+
+ @Test void messageTests() {
+ Message msg = MessagesQueries.getMessage(jdbc, 2817722);
+ User ugnich = msg.User;
+ Assert.assertEquals("ugnich", ugnich.UName);
+ Assert.assertEquals("Microsoft", msg.Tags.get(0));
+ }
}