aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--juick-api/src/main/java/com/juick/api/Others.java1
-rw-r--r--juick-core/src/main/java/com/juick/server/SubscriptionsQueries.java2
-rw-r--r--juick-core/src/main/java/com/juick/server/protocol/JuickProtocol.java2
-rw-r--r--src/test/java/com/juick/tests/ApiTests.java6
-rw-r--r--src/test/resources/schema.sql14
5 files changed, 13 insertions, 12 deletions
diff --git a/juick-api/src/main/java/com/juick/api/Others.java b/juick-api/src/main/java/com/juick/api/Others.java
index 12849f90..6b032531 100644
--- a/juick-api/src/main/java/com/juick/api/Others.java
+++ b/juick-api/src/main/java/com/juick/api/Others.java
@@ -9,7 +9,6 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.sql.Connection;
import java.util.List;
/**
diff --git a/juick-core/src/main/java/com/juick/server/SubscriptionsQueries.java b/juick-core/src/main/java/com/juick/server/SubscriptionsQueries.java
index 21a07e05..a0b91447 100644
--- a/juick-core/src/main/java/com/juick/server/SubscriptionsQueries.java
+++ b/juick-core/src/main/java/com/juick/server/SubscriptionsQueries.java
@@ -80,7 +80,7 @@ public class SubscriptionsQueries {
}
public static boolean subscribeUser(JdbcTemplate sql, User user, User toUser) {
return sql.update("INSERT IGNORE INTO subscr_users(user_id,suser_id) VALUES (?,?)",
- user.getUID(), toUser.getUID()) == 1;
+ toUser.getUID(), user.getUID()) == 1;
}
public static boolean unSubscribeUser(JdbcTemplate sql, User user, User fromUser) {
return sql.update("DELETE FROM subscr_users WHERE suser_id=? AND user_id=?",
diff --git a/juick-core/src/main/java/com/juick/server/protocol/JuickProtocol.java b/juick-core/src/main/java/com/juick/server/protocol/JuickProtocol.java
index 1a2e5333..033417a8 100644
--- a/juick-core/src/main/java/com/juick/server/protocol/JuickProtocol.java
+++ b/juick-core/src/main/java/com/juick/server/protocol/JuickProtocol.java
@@ -152,7 +152,7 @@ public class JuickProtocol {
@UserCommand(pattern = "^(#+)$", help = "# - Show last messages from your feed (## - second page, ...)")
public ProtocolReply commandMyFeed(User user, String... arguments) {
// number of # is the page count
- int page = arguments[0].length();
+ int page = arguments[0].length() - 1;
List<Integer> mids = MessagesQueries.getMyFeed(sql, user.getUID(), page);
List<Message> messages = MessagesQueries.getMessages(sql, mids);
// TODO: add instructions for empty feed
diff --git a/src/test/java/com/juick/tests/ApiTests.java b/src/test/java/com/juick/tests/ApiTests.java
index 5f919c76..5c6cddf3 100644
--- a/src/test/java/com/juick/tests/ApiTests.java
+++ b/src/test/java/com/juick/tests/ApiTests.java
@@ -95,6 +95,7 @@ public class ApiTests {
String baseUri = "http://localhost/";
JuickProtocol protocol = new JuickProtocol(jdbc, baseUri);
MessageSerializer json = new MessageSerializer();
+ assertEquals("juick user should have uid 2", 2, UserQueries.getUIDbyName(jdbc, "juick"));
int uid = UserQueries.createUser(jdbc, "me", "secret");
User user = UserQueries.getUserByUID(jdbc, uid).orElse(new User());
String expectedMessage = "New message posted";
@@ -115,8 +116,9 @@ public class ApiTests {
SubscriptionsQueries.getUsersSubscribedToComments(jdbc, mid, uid).size());
assertEquals("should be subscribed", "Subscribed",
protocol.getReply(readerUser, "S @" + user.getUName()).getDescription());
- /*assertEquals("number of friend users should match", 2,
- UserQueries.getUserFriends(jdbc, readerUid).size());*/
+ List<User> friends = UserQueries.getUserFriends(jdbc, readerUid);
+ assertEquals("number of friend users should match", 2,
+ friends.size());
assertEquals("number of reader users should match", 1,
UserQueries.getUserReaders(jdbc, uid).size());
String expectedReply = "Reply posted.\n#" + mid + "/1 "
diff --git a/src/test/resources/schema.sql b/src/test/resources/schema.sql
index 980573ae..f312db22 100644
--- a/src/test/resources/schema.sql
+++ b/src/test/resources/schema.sql
@@ -274,7 +274,7 @@ CREATE TABLE `meon` (
`name` char(32) NOT NULL,
`ico` smallint(5) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
-) ENGINE=MyISAM AUTO_INCREMENT=10850 DEFAULT CHARSET=utf8;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -307,7 +307,7 @@ CREATE TABLE `messages` (
KEY `place_id` (`place_id`),
KEY `popular` (`popular`),
KEY `hidden` (`hidden`)
-) ENGINE=InnoDB AUTO_INCREMENT=2814769 DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -388,7 +388,7 @@ CREATE TABLE `places` (
`user_id` int(10) unsigned NOT NULL,
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`place_id`)
-) ENGINE=MyISAM AUTO_INCREMENT=2697 DEFAULT CHARSET=utf8;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -480,7 +480,7 @@ CREATE TABLE `reader_links` (
`title` char(255) NOT NULL,
`ts` datetime NOT NULL,
PRIMARY KEY (`link_id`)
-) ENGINE=MyISAM AUTO_INCREMENT=29932 DEFAULT CHARSET=utf8;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -495,7 +495,7 @@ CREATE TABLE `reader_rss` (
`url` char(255) NOT NULL,
`lastcheck` datetime NOT NULL,
PRIMARY KEY (`rss_id`)
-) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -598,7 +598,7 @@ CREATE TABLE `tags` (
`stat_users` smallint(5) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`tag_id`),
KEY `synonym_id` (`synonym_id`)
-) ENGINE=MyISAM AUTO_INCREMENT=115285 DEFAULT CHARSET=utf8;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--
@@ -725,7 +725,7 @@ CREATE TABLE `users` (
`karma` smallint(6) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE KEY `nick` (`nick`)
-) ENGINE=InnoDB AUTO_INCREMENT=29642 DEFAULT CHARSET=utf8;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
--