/core/src/test/java/org/b3log/solo/service/PreferenceQueryServiceTestCase.java
Java | 85 lines | 39 code | 10 blank | 36 comment | 0 complexity | 9bca239a1825b98b0be412ba22267af0 MD5 | raw file
Possible License(s): Apache-2.0, LGPL-2.1
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 */ 16package org.b3log.solo.service; 17 18import org.b3log.latke.model.User; 19import org.b3log.solo.AbstractTestCase; 20import org.b3log.solo.model.Preference; 21import org.json.JSONObject; 22import org.testng.Assert; 23import org.testng.annotations.Test; 24 25/** 26 * {@link PreferenceQueryService} test case. 27 * 28 * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> 29 * @version 1.0.0.0, Feb 1, 2012 30 */ 31@Test(suiteName = "service") 32public class PreferenceQueryServiceTestCase extends AbstractTestCase { 33 34 /** 35 * Init. 36 * 37 * @throws Exception exception 38 */ 39 @Test 40 public void init() throws Exception { 41 final InitService initService = getInitService(); 42 43 final JSONObject requestJSONObject = new JSONObject(); 44 requestJSONObject.put(User.USER_EMAIL, "test@gmail.com"); 45 requestJSONObject.put(User.USER_NAME, "Admin"); 46 requestJSONObject.put(User.USER_PASSWORD, "pass"); 47 48 initService.init(requestJSONObject); 49 50 final UserQueryService userQueryService = UserQueryService.getInstance(); 51 Assert.assertNotNull(userQueryService.getUserByEmail("test@gmail.com")); 52 } 53 54 /** 55 * Get Preference. 56 * 57 * @throws Exception exception 58 */ 59 @Test(dependsOnMethods = "init") 60 public void getPreference() throws Exception { 61 final PreferenceQueryService preferenceQueryService = 62 getPreferenceQueryService(); 63 final JSONObject preference = preferenceQueryService.getPreference(); 64 65 Assert.assertEquals(preference.getString(Preference.BLOG_TITLE), 66 Preference.Default.DEFAULT_BLOG_TITLE); 67 } 68 69 /** 70 * Get Reply Notification Template. 71 * 72 * @throws Exception exception 73 */ 74 @Test(dependsOnMethods = "init") 75 public void getReplyNotificationTemplate() throws Exception { 76 final PreferenceQueryService preferenceQueryService = 77 getPreferenceQueryService(); 78 final JSONObject replyNotificationTemplate = 79 preferenceQueryService.getReplyNotificationTemplate(); 80 81 Assert.assertEquals(replyNotificationTemplate.toString(), 82 Preference.Default.DEFAULT_REPLY_NOTIFICATION_TEMPLATE. 83 toString()); 84 } 85}