/core/src/test/java/org/b3log/solo/service/PreferenceQueryServiceTestCase.java

http://github.com/b3log/b3log-solo · Java · 85 lines · 39 code · 10 blank · 36 comment · 0 complexity · 9bca239a1825b98b0be412ba22267af0 MD5 · raw file

  1. /*
  2. * Copyright (c) 2009, 2010, 2011, 2012, B3log Team
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.b3log.solo.service;
  17. import org.b3log.latke.model.User;
  18. import org.b3log.solo.AbstractTestCase;
  19. import org.b3log.solo.model.Preference;
  20. import org.json.JSONObject;
  21. import org.testng.Assert;
  22. import org.testng.annotations.Test;
  23. /**
  24. * {@link PreferenceQueryService} test case.
  25. *
  26. * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
  27. * @version 1.0.0.0, Feb 1, 2012
  28. */
  29. @Test(suiteName = "service")
  30. public class PreferenceQueryServiceTestCase extends AbstractTestCase {
  31. /**
  32. * Init.
  33. *
  34. * @throws Exception exception
  35. */
  36. @Test
  37. public void init() throws Exception {
  38. final InitService initService = getInitService();
  39. final JSONObject requestJSONObject = new JSONObject();
  40. requestJSONObject.put(User.USER_EMAIL, "test@gmail.com");
  41. requestJSONObject.put(User.USER_NAME, "Admin");
  42. requestJSONObject.put(User.USER_PASSWORD, "pass");
  43. initService.init(requestJSONObject);
  44. final UserQueryService userQueryService = UserQueryService.getInstance();
  45. Assert.assertNotNull(userQueryService.getUserByEmail("test@gmail.com"));
  46. }
  47. /**
  48. * Get Preference.
  49. *
  50. * @throws Exception exception
  51. */
  52. @Test(dependsOnMethods = "init")
  53. public void getPreference() throws Exception {
  54. final PreferenceQueryService preferenceQueryService =
  55. getPreferenceQueryService();
  56. final JSONObject preference = preferenceQueryService.getPreference();
  57. Assert.assertEquals(preference.getString(Preference.BLOG_TITLE),
  58. Preference.Default.DEFAULT_BLOG_TITLE);
  59. }
  60. /**
  61. * Get Reply Notification Template.
  62. *
  63. * @throws Exception exception
  64. */
  65. @Test(dependsOnMethods = "init")
  66. public void getReplyNotificationTemplate() throws Exception {
  67. final PreferenceQueryService preferenceQueryService =
  68. getPreferenceQueryService();
  69. final JSONObject replyNotificationTemplate =
  70. preferenceQueryService.getReplyNotificationTemplate();
  71. Assert.assertEquals(replyNotificationTemplate.toString(),
  72. Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE.
  73. toString());
  74. }
  75. }