You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.7 KiB
67 lines
2.7 KiB
/*
|
|
* Copyright (c) 2019. 黄钰朝
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.hyc.wechat.test;
|
|
|
|
import com.hyc.wechat.model.po.Message;
|
|
import com.hyc.wechat.model.po.Moment;
|
|
import com.hyc.wechat.service.MessageService;
|
|
import com.hyc.wechat.service.MomentService;
|
|
import com.hyc.wechat.service.UserService;
|
|
import com.hyc.wechat.service.impl.MessageServiceImpl;
|
|
import com.hyc.wechat.service.impl.MomentServiceImpl;
|
|
import com.hyc.wechat.service.impl.UserServiceImpl;
|
|
|
|
import java.math.BigInteger;
|
|
import java.sql.Timestamp;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @author <a href="mailto:kobe524348@gmail.com">黄钰朝</a>
|
|
* @description 该类用于测试服务层的各个服务实现类的方法,以确保它们按预期工作。
|
|
* @date 2019-05-06 06:43
|
|
*/
|
|
public class TestService {
|
|
public static void main(String[] args) {
|
|
// 创建UserService实例并测试查询用户列表的方法
|
|
UserService userService = new UserServiceImpl();
|
|
List list = (List) userService.listUserLikeName("昵称").getData();
|
|
System.out.println("查询到:" + list.size() + "个用户");
|
|
|
|
// 创建MessageService实例并测试消息相关的服务方法
|
|
MessageService messageService = new MessageServiceImpl();
|
|
Message message = new Message();
|
|
message.setChatId(BigInteger.valueOf(44));
|
|
message.setSenderId(BigInteger.valueOf(0));
|
|
message.setContent("测试");
|
|
message.setTime(new Timestamp(1111111111L)); // 注意时间戳应该是long类型
|
|
messageService.insertMessage(message);
|
|
messageService.listAllMessage(0, 40, 1);
|
|
messageService.listUnreadMessage(0, 40, 1);
|
|
messageService.setAlreadyRead(0, 40);
|
|
|
|
// 创建MomentService实例并测试朋友圈相关的服务方法
|
|
MomentService momentService = new MomentServiceImpl();
|
|
Moment moment = new Moment();
|
|
moment.setOwnerId(BigInteger.valueOf(0));
|
|
moment.setContent("第一条朋友圈");
|
|
momentService.insertMoment(moment);
|
|
momentService.removeMoment(BigInteger.valueOf(8));
|
|
momentService.listMyMoment(BigInteger.valueOf(0), 1);
|
|
momentService.listNews(BigInteger.valueOf(184), 1);
|
|
}
|
|
}
|